On Sat, 27 Jun 2026 21:15:29 GMT, Daisuke Yamazaki <[email protected]> wrote:

> Added a fast path for `PriorityQueue#addAll` when adding elements to an 
> empty, exact `PriorityQueue` instance.
> 
> Instead of inserting each element one by one through `AbstractQueue#addAll`,
> the implementation now copies the source collection into the backing array 
> and calls `heapify()`.
> This reduces the construction cost for bulk insertion into an empty queue 
> from repeated per-element sift-up work to linear-time heap construction.
> 
> ---------
> - [x] I confirm that I make this contribution in accordance with the [OpenJDK 
> Interim AI Policy](https://openjdk.org/legal/ai).

src/java.base/share/classes/java/util/PriorityQueue.java line 309:

> 307:                     throw new NullPointerException();
> 308:         return es;
> 309:     }

What's the purpose of separating out initElementsFromArray and prepareElements?

Also, does the array needs to get checked for null-objects if it originates 
from a PriorityQueue?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/31701#discussion_r3538039362

Reply via email to