RFR: JDK-8322964 Optimize performance of CSS selector matching [v2]
John Hendrikx
jhendrikx at openjdk.org
Mon Jan 8 16:21:40 UTC 2024
On Mon, 8 Jan 2024 16:01:01 GMT, Andy Goryachev <angorya at openjdk.org> wrote:
>> John Hendrikx has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains eight additional commits since the last revision:
>>
>> - Merge branch 'master' into feature/selector-performance-improvement
>> - Add since tag to new API
>> - Add deprecated annotation and fixed deprecation descriptions
>> - Use copyOf instead of Collections.unmodifiableList(new ArrayList<>(x))
>> - Pull up frozen field to abstract FixedCapacitySet class
>> - Add copyright header
>> - Deprecate StyleClass and remove StyleClassSet for faster solution
>> - Fix regression
>
> modules/javafx.graphics/src/main/java/javafx/css/SimpleSelector.java line 382:
>
>> 380: hash = 31 * (hash + name.hashCode());
>> 381: hash = 31 * (hash + selectorStyleClassNames.hashCode());
>> 382: hash = 31 * (hash + selectorStyleClassNames.hashCode());
>
> this pattern destroys some information that otherwise should be used to produce a better hash code.
> instead of
> `hash = 31 * (hash + newPart);`
> it should be
> `hash = 31 * hash + newPart;`
>
> (also in CompoundSelector)
I agree that it is not nice :) However, changing this seems out of scope for this PR as my changes are unrelated to this, and I didn't even touch `CompoundSelector`. As selectors are never stored in sets/maps, it is hard to justify changing this as part of this PR as it would not be related to improving performance.
-------------
PR Review Comment: https://git.openjdk.org/jfx/pull/1316#discussion_r1444941427
More information about the openjfx-dev
mailing list