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

performance bug in HashMap.putAll

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P5 P5
    • None
    • 1.4.0
    • core-libs
    • None

      There is a performance bug in HashMap.putAll. The logic to pre-expand
      the array is not correct. The code might cause the array to be
      expanded twice instead of once, for example when
              threshold = 8
              size = 7
              t.size() = 15
              loadFactor = 1

      The correction is to add the line
              n += size;
      after the lines
              if (n == 0)
                  return;

            jjb Josh Bloch
            gafter Neal Gafter (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: