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

Unnecessary reallocation when invoking HashMap.putAll()

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P5
    • 13
    • 12
    • core-libs

    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

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: