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

Don't use iterator to modify the underlying Map in mapValuesInPlace #8421

Merged
merged 1 commit into from Sep 16, 2019

Conversation

lrytz
Copy link
Member

@lrytz lrytz commented Sep 16, 2019

Fixes scala/bug#11737.

mutable.Set is not affected, as it doesn't have a mapInPlace method. I also looked through all other xInPlace methods I could find, and didn't see anything suspicious.

In the spirit of scala/bug#7269, this should be back-ported to Map.transform in 2.12/2.11.

Override the method in HashMap with a more efficient implementation.
if (nonEmpty) this match {
case hm: mutable.HashMap[K, V] => hm.mapValuesInPlaceImpl(f)
case _ =>
val array = this.toArray[Any]
Copy link
Member

Choose a reason for hiding this comment

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

We should add some more overrides (in 2.14 or as special cases here in 2.13) to avoid this default implementation.

Copy link
Contributor

Choose a reason for hiding this comment

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

should we add overrides to filterInPlace as well?

@lrytz
Copy link
Member Author

lrytz commented Sep 16, 2019

Merging so we can start the community build. But further reviews are still very welcome.

@lrytz lrytz merged commit 4b35778 into scala:2.13.x Sep 16, 2019
@SethTisue SethTisue modified the milestones: 2.13.2, 2.13.1 Sep 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants