RFR: JDK-8199216: Quadratic layout time with nested nodes and pseudo-class in style sheet [v8]

Nir Lisker nlisker at openjdk.org
Wed Aug 16 07:07:42 UTC 2023


On Tue, 15 Aug 2023 19:33:20 GMT, John Hendrikx <jhendrikx at openjdk.org> wrote:

>> modules/javafx.graphics/src/main/java/com/sun/javafx/css/ImmutablePseudoClassSetsCache.java line 61:
>> 
>>> 59:         CACHE.put(copy, copy);
>>> 60: 
>>> 61:         return copy;
>> 
>> Isn't this just `return CACHE.computeIfAbsent(pseudoClasses, Set::copyOf);`?
>
> Almost, but the key is also the copied set.  In your version the key is the original object, which may be a modifiable set.  If the key is modified, the cache will not function correctly anymore.
> 
> I had a different version before, but @mstr2 pointed out that there was an unnecessary allocation in that version which this version avoids.

Then the map is just an optimization? If the set points to itself then a `Set` as a cache should be enough.

-------------

PR Review Comment: https://git.openjdk.org/jfx/pull/1076#discussion_r1295381418


More information about the openjfx-dev mailing list