On Fri, 21 Aug 2026 19:37:12 GMT, Andy Goryachev <[email protected]> wrote:
>> Why? > > a valid question! using fewer words **is not** a goal. > > the goal is to minimize memory allocation and avoid unnecessary actions > during the pipeline setup. it is possible that `javac` becomes infinitely > smart and will be able to super-optimize the process, but my code does > exactly what I want: create a sorted copy only when needed. Okay, but then `TreeSet` is the worst option since it allocates a new red-black tree node for every element. `Stream.sorted(Comparator)` doesn't do that, it puts all elements into an array and sorts that. But the absolute lowest overhead version of them all is probably `List.sort`: List<PseudoClass> pseudoClasses = new ArrayList<>(selector.getPseudoClassStates()); pseudoClasses.sort(Comparator.comparing(PseudoClass::getPseudoClassName)); ------------- PR Review Comment: https://git.openjdk.org/jfx/pull/2271#discussion_r3833258167
