RFR: 8186958: Need method to create pre-sized HashMap
XenoAmess
duke at openjdk.java.net
Thu Mar 24 00:43:57 UTC 2022
On Thu, 24 Mar 2022 00:39:27 GMT, XenoAmess <duke at openjdk.java.net> wrote:
>> src/java.base/share/classes/java/util/Collections.java line 5826:
>>
>>> 5824: * @since 19
>>> 5825: */
>>> 5826: public static <K, V> HashMap<K, V> newHashMap(int expectedSize) {
>>
>> Stuart [in a JBS comment](https://bugs.openjdk.java.net/browse/JDK-8186958?focusedCommentId=14483078&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-14483078) recommends keeping these factories to the respective classes instead of `Collections`. In existing code, such factories stay in the respective classes, including `ConcurrentHashMap.newKeySet(int)`.
>>
>> Since this is an API change, I suggest you determine where the methods will stay before filing a CSR request.
>
> good but I have no account to comment on your jira system.
still I think it better to put these functions to Collections as they can share a same calculation function.
-------------
PR: https://git.openjdk.java.net/jdk/pull/7928
More information about the core-libs-dev
mailing list