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

Archie Cobbs acobbs at openjdk.org
Thu May 15 17:46:39 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.

Archie Cobbs has updated the pull request incrementally with one additional commit since the last revision:

  Add benchmark for ArrayDeque.clear().

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/25237/files
  - new: https://git.openjdk.org/jdk/pull/25237/files/84fb0903..1b8fb830

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=25237&range=01
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=25237&range=00-01

  Stats: 69 lines in 1 file changed: 69 ins; 0 del; 0 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