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

(coll) PriorityQueue.grow resizes internal array by 4, not 2

XMLWordPrintable

      PriorityQueue.grow has this code:

                   if (newlen >= Integer.MAX_VALUE / 2) // avoid overflow
                      newlen = Integer.MAX_VALUE;
                  else
                      newlen <<= 2;

      That shift grows by 4. The intended action was certainly

       newlen <<= 1;

      The current code fails when the internal array is between
      Integer.MAX_VALUE/4 and Integer.MAX_VALUE/2,
      and is needlessly wasteful of memory in other cases.

            martin Martin Buchholz
            martin Martin Buchholz
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: