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

Archie Cobbs acobbs at openjdk.org
Wed May 14 19:43:20 UTC 2025


Please review this small performance tweak `ArrayDeque`.

`ArrayDeque` has an invariant in which any unused elements in the array must be null. In a couple of places, the code is setting contiguous ranges of elements to null using `for()` loops. This can be both simplified and sped up by using `Arrays.fill()` instead.

-------------

Commit messages:
 - Use Arrays.fill() instead of for() loops to null out array elements.

Changes: https://git.openjdk.org/jdk/pull/25237/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=25237&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8356993
  Stats: 3 lines in 1 file changed: 0 ins; 1 del; 2 mod
  Patch: https://git.openjdk.org/jdk/pull/25237.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/25237/head:pull/25237

PR: https://git.openjdk.org/jdk/pull/25237


More information about the core-libs-dev mailing list