On Thu, 3 Aug 2023 15:22:39 GMT, Marius Hanl <mh...@openjdk.org> wrote:

>> John Hendrikx has updated the pull request with a new target base due to a 
>> merge or a rebase. The pull request now contains 16 commits:
>> 
>>  - Merge branch 'master' of https://git.openjdk.org/jfx into
>>    feature/immutable-pseudoclassstate
>>  - Merge remote-tracking branch 'upstream/master' into 
>> feature/immutable-pseudoclassstate
>>  - Avoid using Lambda in ImmutablePseudoClassSetsCache.of()
>>  - Merge branch 'master' of https://git.openjdk.org/jfx into
>>    feature/immutable-pseudoclassstate
>>  - Fix another edge case in BitSet equals
>>    
>>    When arrays are not the same size, but there are no set bits in the ones
>>    the other set doesn't have, two bit sets can still be considered equal
>>  - Take element type into account for BitSet.equals()
>>  - Base BitSet on AbstractSet to inherit correct equals/hashCode/toArray
>>    
>>    - Removed faulty toArray implementations in PseudoClassState and
>>    StyleClassSet
>>    - Added test that verifies equals/hashCode for PseudoClassState respect
>>    Set contract now
>>    - Made getBits package private so it can't be inherited
>>  - Remove unused code
>>  - Ensure Match doesn't allow modification
>>  - Simplify ImmutablePseudoClassSetsCache and avoid an unnecessary copy
>>  - ... and 6 more: https://git.openjdk.org/jfx/compare/9ad0e908...7975ae99
>
> modules/javafx.graphics/src/main/java/javafx/scene/CssStyleHelper.java line 
> 582:
> 
>> 580:         }
>> 581: 
>> 582:         if (count == depth) {
> 
> Can you explain why we can return here?

Yes, we want to return a `Set[]` which has pseudo class state information for 
each nesting level of `Node`, as each entry in the array represents a nesting 
level (0 = `Node`, 1 = parent, 2 = parent.parent, etc.).  We allocate the array 
with the maximum possible nesting level (`depth`).  The loop then runs to fill 
in each level.  It's possible however that a level is unused, and in that case 
the array would be too long, so it must be trimmed.   If however all levels 
were used, there's no need to reallocate the array and we can return early.

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

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

Reply via email to