RFR: JDK-8322964 Optimize performance of CSS selector matching [v2]
Andy Goryachev
angorya at openjdk.org
Mon Jan 8 16:25:36 UTC 2024
On Mon, 8 Jan 2024 16:19:05 GMT, John Hendrikx <jhendrikx at openjdk.org> wrote:
>> 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.
these lines discard about 4.5 bits of information on each step, surely that will affect performance, no?
-------------
PR Review Comment: https://git.openjdk.org/jfx/pull/1316#discussion_r1444947194
More information about the openjfx-dev
mailing list