ArrayDeque should use Arrays.fill() instead of for() loops

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Won't Fix
    • Priority: P4
    • None
    • Affects Version/s: 25
    • Component/s: core-libs
    • Environment:

      jdk-25+22-94-g0318e49500e

    • generic
    • generic

      I happened to notice a couple of places in ArrayDeque where the code is setting a contiguous range of Object[] elements to null using a for() loop. This is done to preserve the invariant that unused elements in the array are always null.

      These clear operations should be done instead with Arrays.fill(), which is presumably faster.

      The two spots are in the methods grow() and circularClear().

            Assignee:
            Archie Cobbs
            Reporter:
            Archie Cobbs
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: