Unnecessary reallocation when invoking HashMap.putAll()

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P5
    • 13
    • Affects Version/s: 12
    • Component/s: core-libs

      This issue was brought up during review of the fix for JDK-8207314:

      http://mail.openjdk.java.net/pipermail/core-libs-dev/2018-July/054403.html

      ---- by Martin ----
      HashMap's resize() doesn't take an arg, while WeakHashMap's does. Why?
      As a result, I see in HashMap.putMapEntries

                  else if (s > threshold)
                      resize();

      which suggests that if you create a fresh HashMap, then putAll(hugeMap) it
      will repeatedly resize instead of resizing to the target capacity in one
      step. Which seems like a HashMap bug.

            Assignee:
            Michal Vala
            Reporter:
            Ivan Gerasimov
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: