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

Change RealMultibinder#doProvision to use ImmutableSet#buildWithExpectedSize, and avoid an extra T[] array allocation when permitDuplicates==true. #1789

Merged
merged 1 commit into from
Jan 10, 2024

Commits on Jan 10, 2024

  1. Change RealMultibinder#doProvision to use ImmutableSet#buildWithExpec…

    …tedSize, and avoid an extra T[] array allocation when permitDuplicates==true.
    
    Since the normal usage should be that the items in the values array are all unique, and ImmutableSet#copyOf will create an initial list of max(4, sqrt(length)) if length>4, but then grows that list to length (or larger) if the array was all unique (and then resize is back down during build()).
    
    While here, the T[] values array is also only needed to be filled in when permitDuplicates==false (for the error message if duplicates were detected).
    
    PiperOrigin-RevId: 597244931
    java-team-github-bot authored and Guice Team committed Jan 10, 2024
    Configuration menu
    Copy the full SHA
    21d26cf View commit details
    Browse the repository at this point in the history