changeset 51187:e55d46250431

8207314: Unnecessary reallocation when constructing WeakHashMap from a large Map Reviewed-by: martin
author igerasim
date Mon, 23 Jul 2018 22:07:55 -0700
parents 22e1b5900d90
children 630b5e06a947
files src/java.base/share/classes/java/util/WeakHashMap.java
diffstat 1 files changed, 1 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/java/util/WeakHashMap.java	Mon Jul 23 18:29:35 2018 -0700
+++ b/src/java.base/share/classes/java/util/WeakHashMap.java	Mon Jul 23 22:07:55 2018 -0700
@@ -252,7 +252,7 @@
      * @since   1.3
      */
     public WeakHashMap(Map<? extends K, ? extends V> m) {
-        this(Math.max((int) (m.size() / DEFAULT_LOAD_FACTOR) + 1,
+        this(Math.max((int) ((float)m.size() / DEFAULT_LOAD_FACTOR + 1.0F),
                 DEFAULT_INITIAL_CAPACITY),
              DEFAULT_LOAD_FACTOR);
         putAll(m);