[PATCH]: Code optimization for BitSet
Fabio Romano
fabio19298 at gmail.com
Wed Jan 11 12:47:36 UTC 2023
The cardinality is saved as a field, new method for testing subset relation.
The enanchment is useful for applications that make heavy use of BitSet
objects as sets of integers, and therefore they need to make a lot of calls
to cardinality() method, which actually require linear time in the number
of words in use by the bit set.
This optimization reduces the cost of calling cardinality() to constant
time, as it simply returns the value of the field, and it also try to make
as little effort as possible to update the field, when needed.
Moreover, it has been implemented a new method for testing wheter a bit set
includes another bit set (i.e., the set of true bits of the parameter is a
subset of the true bits of the instance).
Link to the pull request: https://github.com/openjdk/jdk/pull/11837
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/jdk-dev/attachments/20230111/0fa030ff/attachment.htm>
More information about the jdk-dev
mailing list