On Tue, 5 Sep 2023 13:09:46 GMT, John Hendrikx <jhendr...@openjdk.org> wrote:

>> modules/javafx.graphics/src/main/java/com/sun/javafx/css/BitSet.java line 
>> 549:
>> 
>>> 547: 
>>> 548:         for (int i = 0; i < max; i++) {
>>> 549:             long m0 = i >= a ? 0 : this.bits[i];
>> 
>> Are we guaranteed that it is an invariant of this Class that there will 
>> never be an entry in `bits` that is `0`? From the code, it looks like that 
>> is the case (at least when inspecting add and remove), but it's not enforced 
>> I believe (e.g. subclasses may violate this rule). 
>> This remark is irrelevant if we consider 2 BitSets to be equal if their 
>> length is not equal, but the entries that are only in 1 of the sets are 
>> always 0.
>
>> Are we guaranteed that it is an invariant of this Class that there will 
>> never be an entry in bits that is 0?
> 
> Unfortunately not, the `remove` code does not shrink the array (it only 
> shrinks when all bits were cleared, not when only the bits were cleared in 
> higher `long` locations).

Note that this is rare anyway, these sets were rarely mutated (if ever), which 
is also the reason why this caching change was easy to do.  This is also why it 
never broke in practice.

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

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

Reply via email to