Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8210280

Unnecessary reallocation when invoking HashMap.putAll()

    XMLWordPrintable

    Details

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

      Description

      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.

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved: