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

Conversation

jsbean
Copy link
Contributor

@jsbean jsbean commented Apr 29, 2019

This PR uses a map over key-value pairs instead of mapValues along with shuffled() when transforming attributes into a Box-ed representation within XMLCoderElement.flatten().

At first, I was wondering what the shuffled() was for. I tried to get rid of it on its own, but the compiler didn't appreciate that very much when it came to KeyedStorage.init<S>(_ sequence: S) where S: Sequence, S.Element == (Key, Value). Could this be a moment of ambiguity between (Key,Value) and (key: Key, value: Value)?

Ultimately, mapValues alone should do the trick, but I thought it might be nice to avoid another O(n) pass if not necessary.

Did shuffled have any other purpose than juggling types with the compiler?

@codecov
Copy link

codecov bot commented Apr 30, 2019

Codecov Report

Merging #93 into master will decrease coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #93      +/-   ##
==========================================
- Coverage   76.98%   76.97%   -0.02%     
==========================================
  Files          38       38              
  Lines        2112     2111       -1     
==========================================
- Hits         1626     1625       -1     
  Misses        486      486
Impacted Files Coverage Δ
Sources/XMLCoder/Auxiliaries/XMLCoderElement.swift 97.15% <100%> (-0.02%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5cd2ebb...aa86b9a. Read the comment docs.

Copy link
Collaborator

@MaxDesiatov MaxDesiatov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, thank you @jsbean! Indeed, there was no point in shuffled() other than appeasing the type checker.

@MaxDesiatov MaxDesiatov merged commit 38a0f17 into CoreOffice:master Apr 30, 2019
@jsbean jsbean deleted the bean/de-shuffle branch July 11, 2019 20:55
arjungupta0107 pushed a commit to salido/XMLCoder that referenced this pull request Jun 26, 2020
…Office#93)

* Use map instead of mapValues in XMLCoderElement.flatten
* Remove whitespace
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants