Skip to content

mutable.HashMap should override 'foreachEntry' to avoid tuple allocation#9425

Merged
lrytz merged 1 commit into
scala:2.13.xfrom
chia7712:MINOR-9425
Jan 11, 2021
Merged

mutable.HashMap should override 'foreachEntry' to avoid tuple allocation#9425
lrytz merged 1 commit into
scala:2.13.xfrom
chia7712:MINOR-9425

Conversation

@chia7712

@chia7712 chia7712 commented Jan 8, 2021

Copy link
Copy Markdown
Contributor

The method foreachEntry is a hot method in our project and I noticed that mutable.HashMap does not override foreachEntry so default implementation (Map#foreachEntry) creates many tuple2. We should do the improvement like b88a55d for mutable.HashMap

@ijuma ijuma left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks like this was somehow missed in the original commit.

@NthPortal NthPortal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@SethTisue SethTisue added library:collections PRs involving changes to the standard collection library performance the need for speed. usually compiler performance, sometimes runtime performance. labels Jan 8, 2021
@lrytz lrytz merged commit 5273aaf into scala:2.13.x Jan 11, 2021
ijuma added a commit to apache/kafka that referenced this pull request Feb 23, 2021
This includes a fix from Chia-Ping that removes tuple
allocations when `Map.forKeyValue` is used
(scala/scala#9425) and support
for JDK 16.

Release notes:
https://github.com/scala/scala/releases/tag/v2.13.5

Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
ijuma added a commit to apache/kafka that referenced this pull request Feb 23, 2021
This includes a fix from Chia-Ping that removes tuple
allocations when `Map.forKeyValue` is used
(scala/scala#9425) and support
for JDK 16.

Release notes:
https://github.com/scala/scala/releases/tag/v2.13.5

Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
hamzaremmal pushed a commit to hamzaremmal/scala3 that referenced this pull request May 2, 2025
mutable.HashMap should override 'foreachEntry' to avoid tuple allocation
hamzaremmal pushed a commit to scala/scala3 that referenced this pull request May 7, 2025
mutable.HashMap should override 'foreachEntry' to avoid tuple allocation
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 performance the need for speed. usually compiler performance, sometimes runtime performance.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants