< prev index next >

src/java.base/share/classes/java/util/HashMap.java

Print this page

        

*** 499,511 **** float ft = ((float)s / loadFactor) + 1.0F; int t = ((ft < (float)MAXIMUM_CAPACITY) ? (int)ft : MAXIMUM_CAPACITY); if (t > threshold) threshold = tableSizeFor(t); ! } ! else if (s > threshold) resize(); for (Map.Entry<? extends K, ? extends V> e : m.entrySet()) { K key = e.getKey(); V value = e.getValue(); putVal(hash(key), key, value, false, evict); } --- 499,516 ---- float ft = ((float)s / loadFactor) + 1.0F; int t = ((ft < (float)MAXIMUM_CAPACITY) ? (int)ft : MAXIMUM_CAPACITY); if (t > threshold) threshold = tableSizeFor(t); ! } else { ! // Because of linked-list buckets constraints, we cannot ! // expand all at once, but can reduce total resize ! // effort by repeated doubling now vs later ! while (table.length < MAXIMUM_CAPACITY && s > threshold) { resize(); + } + } for (Map.Entry<? extends K, ? extends V> e : m.entrySet()) { K key = e.getKey(); V value = e.getValue(); putVal(hash(key), key, value, false, evict); }
< prev index next >