On Tue, 4 Nov 2025 19:44:01 GMT, Johannes Döbler <[email protected]> wrote:
>> I think peeling off and outlining distinct paths in a larger method to >> separate, simpler methods usually reduces distracting noise and improves >> readability, but I guess that's subjective territory. > >> cl4es: Consider simplifying this to reduce code duplication: > > or even simpler? > > > Object[] a = c.getClass() == ArrayList.class ? ((ArrayList<?>)c).elementData > : a.toArray(); > int newNum = a.length; > ... > > > >> jengebr: Interestingly, this hurt the fast-path about 5%, but the control >> case about 35%. > > what is the control case, LinkedList.addAll() ? No, ArrayList.addAll(LinkedList). This is the slow path that ideally will perform the same as before this change - and the initial change achieves that. Rewriting to reduce duplication increased runtime of both the optimized and control. I'll benchmark your suggestion as well. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/28116#discussion_r2491902162
