Re: RFR: 8332842: Optimize empty CopyOnWriteArrayList allocations [v2]

2024-06-05 Thread jengebr
On Tue, 4 Jun 2024 19:58:41 GMT, jengebr wrote: >> Agreed. You might as well be consistent with this so that no one will need >> to re-address if some application does zillions of clones of empty lists. > > Sorry, I crossed wires with @DougLea 's comment, will add `clone`. `clone()` performs a

Re: RFR: 8332842: Optimize empty CopyOnWriteArrayList allocations [v2]

2024-06-04 Thread jengebr
On Tue, 4 Jun 2024 19:41:15 GMT, Doug Lea wrote: >> src/java.base/share/classes/java/util/concurrent/CopyOnWriteArrayList.java >> line 103: >> >>> 101: private static final long serialVersionUID = 8673264195747942595L; >>> 102: >>> 103: private static final Object[] EMPTY_ELEMENTDATA =

Re: RFR: 8332842: Optimize empty CopyOnWriteArrayList allocations [v2]

2024-06-04 Thread jengebr
> Improve `java/util/concurrent/CopyOnWriteArrayList` by eliminating needless > cloning of Object[0] instances. This cloning is intended to prevent callers > from changing array contents, but many `CopyOnWriteArrayList`s are allocated > to size zero, or are otherwise maintained empty, so cloning