On Fri, 21 Aug 2026 19:55:20 GMT, Michael Strauß <[email protected]> wrote:
>> 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)); how many pseudoclasses so we have in a selector, realistically speaking? a few, really. but there was one issue with my code - no sorting is necessary if the number of pseudoclasses is less than 2. ------------- PR Review Comment: https://git.openjdk.org/jfx/pull/2271#discussion_r3833293918
