RFR 8170159 Improve the performance of BitSet traversal

Martin Buchholz martinrb at google.com
Fri Jun 15 21:24:19 UTC 2018


Still looks correct, but I might keep looking for something  more elegant.
What bothers me a little now is

1290                         long word = words[u] & (WORD_MASK << i);


which is part of the initial setup and is not necessary on each iteration.

On Fri, Jun 15, 2018 at 1:13 PM, Paul Sandoz <paul.sandoz at oracle.com> wrote:

> Thanks! Doh, obvious in hindsight.
>
> On Jun 15, 2018, at 11:05 AM, Martin Buchholz <martinrb at google.com> wrote:
>
> It took me a while to realize why you were checking tz < 63.  It's because
> the shift by 64 that might occur below would be a no-op!
>
>
> Right!
>
> 1301                             action.accept(i++);1302                             word &= (WORD_MASK << i);
>
> Can we rewrite to simply flip the one bit via
>
> word &= ~(1L << i);
> action.accept(i++);
>
> and then we can simplify the tz handling?
>
>
> Yes, and there is no need to increment i:
>
>   http://cr.openjdk.java.net/~psandoz/jdk/JDK-8170159-
> bitset-traverse/webrev/src/java.base/share/classes/java/
> util/BitSet.java.sdiff.html
>
> Paul.
>


More information about the core-libs-dev mailing list