On Tue, 25 Apr 2023 05:40:13 GMT, John Hendrikx <jhendr...@openjdk.org> wrote:

>> modules/javafx.graphics/src/main/java/com/sun/javafx/css/BitSet.java line 
>> 546:
>> 
>>> 544:         }
>>> 545:         if (obj instanceof BitSet<?> bitSet) {  // fast path if other 
>>> is a BitSet
>>> 546:             return equalsBitSet(bitSet);
>> 
>> I suspect this will not work
>> BitSet<Integer> will never be equal to BitSet<String>, does it mean we have 
>> to do a per-element comparison?
>
>> I suspect this will not work BitSet will never be equal to BitSet, does it 
>> mean we have to do a per-element comparison?
> 
> If I understand correctly, you're pointing out that if you have two bit sets, 
> of different element types (currently in use we have 
> `BitSet<PseudoClassState>` and `BitSet<StyleClass>`) but they have the same 
> bit pattern and size, that they could be considered equals.
> 
> This is a good point, and a problem that has been part of `BitSet` since its 
> inception.

I've fixed this problem, and while fixing it discovered another (existing) 
problem, which I also fixed:

It turns out that two `BitSet`s that have different internal array sizes are 
always considered not equal; but if I add elements to one `BitSet`, forcing its 
internal array to grow, but then remove them again, then the array isn't 
shrunk...

Added tests as well to cover these cases.

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

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

Reply via email to