Skip to content

Conversation

retronym
Copy link
Member

Cherry picking from #8411 with a 2.13.x twist.

Because foreachEntry is part of the MapOps API, we can now centralize
the optimization in MurmurHash3.mapHash, other than for the
hand-inlined implementations ins MapN that seek to avoid even
the allocation of the accumulator function.

@scala-jenkins scala-jenkins added this to the 2.13.2 milestone Sep 30, 2019
@retronym retronym requested a review from szeiger September 30, 2019 04:02
@retronym
Copy link
Member Author

Split out of #8440

@retronym retronym force-pushed the topic/map-hashcode-2.13.x branch 2 times, most recently from fc66e18 to 32d00cd Compare September 30, 2019 23:51
t0.##
}

onlyAllocates(256) {
Copy link
Member Author

Choose a reason for hiding this comment

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

This is higher than in the 2.12.x version because we use ChampBaseIterator which avoids using the JVM stack during iteration into the Trie.

@diesalbla diesalbla added the library:collections PRs involving changes to the standard collection library label Oct 8, 2019
ProblemFilters.exclude[DirectMissingMethodProblem]("scala.collection.immutable.RedBlackTree.countInRange"),
ProblemFilters.exclude[DirectMissingMethodProblem]("scala.util.hashing.MurmurHash3.emptyMapHash"),
ProblemFilters.exclude[DirectMissingMethodProblem]("scala.util.hashing.MurmurHash3.tuple2Hash"),
ProblemFilters.exclude[MissingTypesProblem]("scala.collection.immutable.MapKeyValueTupleHashIterator"),
Copy link
Contributor

Choose a reason for hiding this comment

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

The class exists in the old and new version. Is this a false positive in MiMa?

Copy link
Member Author

Choose a reason for hiding this comment

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

This class still exists, but it no longer extends Product2. The MissingTypesProblem entry ignores that problem as it is not in user facing code.

Comment on lines 83 to 85
/** Apply `f` to each key/value pair for its side effects
* Note: [U] parameter needed to help scalac's type inference.
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

scaladoc comment can be omitted; it is identical to the inherited one

f(curr.key, curr.value)
curr = curr.next
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this going to present key-values in the wrong order, since ListMap is stored in reverse?

Copy link
Member Author

Choose a reason for hiding this comment

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

You are right. This is okay for the hashCode computation (which is order-agnostic), but doesn't seem suitable for the general foreachEntry method.

Copy link
Member Author

@retronym retronym Oct 14, 2019

Choose a reason for hiding this comment

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

I've now removed this override other than in a private helper class used in ListMap.hashCode. I've also overridden foreachEntry in SeqMapN.

@retronym retronym force-pushed the topic/map-hashcode-2.13.x branch from 32d00cd to 8d77d55 Compare October 14, 2019 02:58
Cherry picking from scala#8411 with a 2.13.x twist.

Because foreachEntry is part of the MapOps API, we can now centralize
the optimization in MurmurHash3.mapHash, other than for the
hand-inlined implementations ins MapN that seek to avoid even
the allocation of the accumulator function.
@retronym retronym force-pushed the topic/map-hashcode-2.13.x branch from 8d77d55 to e6cb836 Compare October 22, 2019 03:35
@retronym retronym merged commit dc7f885 into scala:2.13.x Oct 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

library:collections PRs involving changes to the standard collection library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants