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

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

    Details

      Description

      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.

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: