Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use map instead of mapValues/shuffle in XMLCoderElement.flatten #93

Merged
merged 2 commits into from Apr 30, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 3 additions & 4 deletions Sources/XMLCoder/Auxiliaries/XMLCoderElement.swift
Expand Up @@ -45,11 +45,10 @@ struct XMLCoderElement: Equatable {
}

func flatten() -> KeyedBox {
let attributes = KeyedStorage(self.attributes.mapValues {
StringBox($0) as SimpleBox
}.shuffled())
let attributes = KeyedStorage(self.attributes.map { (key, value) in
(key: key, value: StringBox(value) as SimpleBox)
})
let storage = KeyedStorage<String, Box>()

var elements = self.elements.reduce(storage) { $0.merge(element: $1) }

// Handle attributed unkeyed value <foo attr="bar">zap</foo>
Expand Down