< prev index next >
src/java.base/share/classes/java/util/WeakHashMap.java
Print this page
rev 51180 : [mq]: 8207314-Unnecessary-reallocation-when-constructing-WeakHashMap-from-a-large-Map
*** 250,260 ****
* @param m the map whose mappings are to be placed in this map
* @throws NullPointerException if the specified map is null
* @since 1.3
*/
public WeakHashMap(Map<? extends K, ? extends V> m) {
! this(Math.max((int) (m.size() / DEFAULT_LOAD_FACTOR) + 1,
DEFAULT_INITIAL_CAPACITY),
DEFAULT_LOAD_FACTOR);
putAll(m);
}
--- 250,260 ----
* @param m the map whose mappings are to be placed in this map
* @throws NullPointerException if the specified map is null
* @since 1.3
*/
public WeakHashMap(Map<? extends K, ? extends V> m) {
! this(Math.max((int) ((float)m.size() / DEFAULT_LOAD_FACTOR + 1.0F),
DEFAULT_INITIAL_CAPACITY),
DEFAULT_LOAD_FACTOR);
putAll(m);
}
< prev index next >