scala / collection-strawman

Implementation of the new Scala 2.13 Collections
Apache License 2.0
200 stars 72 forks source link

Override HashMap.default in Seq.occCounts instead of using Map.withDefaultValue #482

Closed marcelocenerine closed 6 years ago

marcelocenerine commented 6 years ago

Reverting a small change I made here. It was not needed for the purpose of that PR (turns out the anonymous class is only used internally) and can slightly increase the running time of diff and intersect. This is likely caused by the fact that Map.withDefaultValue wraps the default value in a function causing an additional dispatch every time a key is missing.

image

julienrf commented 6 years ago

Your benchmark seems to show that performance was slightly better before the PR, no?

marcelocenerine commented 6 years ago

sorry @julienrf , Red line is before #444 Blue line is after #444 (which is what this PR aims to revert)

julienrf commented 6 years ago

Ah, thanks for the clarification!