Apply consistent rules for key & value identities to maps and sets#7481
Apply consistent rules for key & value identities to maps and sets#7481lrytz merged 1 commit intoscala:2.13.xfrom
Conversation
|
@Ichoran I've added an Original: inline seekEntryOrOpen: Simple fix (from the old version of this PR): Simple fix with inline seekEntryOrOpen: |
|
That's encouraging! I'm not sure the tupling clarifies rather than confuses the logic, though, given the other places that bit inspection is used. The various |
The rules are listed in `SetMapRulesTest`. All collections changes are necessary to comply with rule 3 (key identity). The other rules were not violated by any of the tested collections. Fixes scala/bug#10415
|
@Ichoran I think I understand what you mean. I didn't really look at the various bits too closely before. I've updated the code to make use of the returned bits so we don't need to get the old key at all. |
This was left over from 2.12 when they old key would be overwritten. The behavior changed in scala#7481 to comply with the new map/set rules in scala/bug#10415 (comment). I would also call it wrong in 2.12 because equality should be defined exclusively by the Ordering, but we should keep the current behavior for compatibility reasons.
Changes from: scala#7481 scala#8783 Backported in: scala@b87dd51#diff-f99536a3327e638dcf239518f2c3f0ceR195 scala@93afae7#diff-f99536a3327e638dcf239518f2c3f0ceL214 ... are reverted. I've added a test for the legacy behaviour that we don't want to break.
This was left over from 2.12 when they old key would be overwritten. The behavior changed in scala/scala#7481 to comply with the new map/set rules in scala/bug#10415 (comment). I would also call it wrong in 2.12 because equality should be defined exclusively by the Ordering, but we should keep the current behavior for compatibility reasons.
Changes from: scala/scala#7481 scala/scala#8783 Backported in: scala/scala@3b637df#diff-f99536a3327e638dcf239518f2c3f0ceR195 scala/scala@1b39caf#diff-f99536a3327e638dcf239518f2c3f0ceL214 ... are reverted. I've added a test for the legacy behaviour that we don't want to break.
This was left over from 2.12 when they old key would be overwritten. The behavior changed in scala/scala#7481 to comply with the new map/set rules in scala/bug#10415 (comment). I would also call it wrong in 2.12 because equality should be defined exclusively by the Ordering, but we should keep the current behavior for compatibility reasons.
Changes from: scala/scala#7481 scala/scala#8783 Backported in: scala/scala@9bfb183#diff-f99536a3327e638dcf239518f2c3f0ceR195 scala/scala@48809df#diff-f99536a3327e638dcf239518f2c3f0ceL214 ... are reverted. I've added a test for the legacy behaviour that we don't want to break.
The rules are listed in
SetMapRulesTest. All collections changesare necessary to comply with rule 3 (key identity). The other rules
were not violated by any of the tested collections.
Fixes scala/bug#10415
There may be more elegant or efficient ways to fix some of the collections but I wanted to get this out before the weekend for some feedback. I fixed the following collections:
immutable.HashMapandimmutable.HashSetmay be slightly faster nowmutable.ListMap,mutable.AnyRefMapand immutable.ListMap could be slightly slowerconcurrent.TrieMapand immutable.TreeMap should not show any effects on performanceSomeone should look over the changes I made to
TrieMapandAnyRefMapbecause I am not very familiar with these. The rest was quite straight-forward.