On Sun, 23 Aug 2026 18:05:08 GMT, Marius Hanl <[email protected]> wrote:
>> 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. > > I would also rather like to see a `List` here. > Right now, `Set<PseudoClass> pseudoClassStates = > selector.getPseudoClassStates();` reads like we do not care about the order, > just to see that we do care about it right after by using a `TreeSet`. > > IMO we should not have a `Set` at all here, so if we for example write: > `List<PseudoClass> pseudoClassStates = > selector.getPseudoClassStates().stream().sorted(Comparator.comparing(PseudoClass::getPseudoClassName)).toList();`, > it is immediately clear that we care about the order and we always use a > `List`, never a `Set`. In this particular case, `Set<>` is fine - there is no point in having duplicate pseudoclasses, and the order should not matter (I would be very surprised to see different result for `:focused:selected` vs `:selected:focused` ) But I came to like @mstr2 's suggestion with the `ArrayList<>`. ------------- PR Review Comment: https://git.openjdk.org/jfx/pull/2271#discussion_r3844873880
