<i18n dev> RFR: 8186958: Need method to create pre-sized HashMap [v18]

Stuart Marks smarks at openjdk.java.net
Wed Apr 13 23:06:16 UTC 2022


On Wed, 13 Apr 2022 22:20:14 GMT, XenoAmess <duke at openjdk.java.net> wrote:

>> 8186958: Need method to create pre-sized HashMap
>
> XenoAmess has updated the pull request incrementally with one additional commit since the last revision:
> 
>   update LastModified

src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSAttributeChecker.java line 1819:

> 1817:     Map<String, OneAttr> items;
> 1818:     LargeContainer(int size) {
> 1819:         items = HashMap.newHashMap(size*2+1);

I'm wondering if we should change this to just `newHashMap(size)` since it looks like this container is intended to hold up to `size` items. @JoeWang-Java ? I suspect the `size*2+1` was a failed attempt at allocating a HashMap of the correct capacity for `size` mappings.

-------------

PR: https://git.openjdk.java.net/jdk/pull/7928


More information about the i18n-dev mailing list