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

Adjust the capacity computation in Maps.newHashMapWithExpectedSize. #5980

Closed
wants to merge 1 commit into from

Conversation

copybara-service[bot]
Copy link
Contributor

Adjust the capacity computation in Maps.newHashMapWithExpectedSize.

This JDK change fixed the computation used when the first write to a HashMap is putAll(otherMap). Previously that would occasionally lead to an unnecessarily large internal table. That same computation was copied into Maps.newHashMapWithExpectedSize, so it should also be adjusted.

Thanks to @XenoAmess for both the JDK fix and the fix here.

Closes #5965.

RELNOTES=Maps.newHashMapWithExpectedSize sometimes allocated maps that were larger than they needed to be.

[This JDK change](openjdk/jdk@3e39304) fixed the computation used when the first write to a `HashMap` is `putAll(otherMap)`. Previously that would occasionally lead to an unnecessarily large internal table. That same computation was copied into `Maps.newHashMapWithExpectedSize`, so it should also be adjusted.

Thanks to @XenoAmess for both the JDK fix and the fix here.

Closes #5965.

RELNOTES=`Maps.newHashMapWithExpectedSize` sometimes allocated maps that were larger than they needed to be.
PiperOrigin-RevId: 436318398
@copybara-service copybara-service bot force-pushed the test_436318398 branch 2 times, most recently from ae46196 to 6ad621e Compare March 22, 2022 14:14
@copybara-service copybara-service bot closed this Mar 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant