Use HashMap#newHashMap, HashSet#newHashSet instead of CollectionUtil#newHashMap, CollectionUtil#newHashSet.#15517
Conversation
|
Hello, @uschindler |
|
Hi, The plus1 issue comes from a safety added, I think because @thecoop wanted to make sure that after rounding the size is correct. According to JDK docs the newHashXxx method in jdk ensures that the requested elements fit into the map without resizing. So they .ay gave changed other stuff to make the plus1 not needed. Uwe |
|
Yup, these CollectionUtil methods can just be removed and the JCL methods used directly. There'll need to be a changelog entry documenting the API removal. CollectionUtil is marked as internal, so we can just remove these for Lucene 11 |
|
Thanks @uschindler, @thecoop. I considered use the JDK methods directly, but chosed this way. Anyway, I will fix it. |
…wHashMap, HashSet.newHashSet directly.
|
Hi @uschindler , @thecoop This pr also plus 1 for |
| } | ||
| final Map<String, String> map = CollectionUtil.newHashMap(params.length / 2); | ||
| // Plus 1 since applyDefaultParams will add a default param later. | ||
| final Map<String, String> map = HashMap.newHashMap(params.length / 2 + 1); |
|
Merry Xmas! 🎄 |
|
Merry Xmas! 🎄 I will backport this to 10.x |
|
For 10.x maybe keep the CollectionUtil method as deprecated. |
…il#newHashMap and CollectionUtil#newHashSet. (#15517). But keep CollectionUtil's methods as deprecated.
Description
Discussed in #14770.