Yonik,

You are the best. If you look at the test, its also broken somehow, because
it uses length vs. size() wrong (I already reopened the
https://issues.apache.org/jira/browse/LUCENE-3179 issue).

And please stop ranting about Java 5, it helped to find a bug in this impl,
its really broken as OpenBitSet always allows indexes >= size (except fast*
methods).

Uwe

-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: [email protected]


> -----Original Message-----
> From: [email protected] [mailto:[email protected]] On Behalf Of Yonik
> Seeley
> Sent: Friday, June 24, 2011 6:29 PM
> To: [email protected]
> Subject: Re: [VOTE] release 3.3
> 
> On Fri, Jun 24, 2011 at 12:14 PM, Yonik Seeley
<[email protected]>
> wrote:
> > All that needs to be done is to move the negative index check to the
> > bottom (the first index<0 is not needed since we do a signed shift).
> >
> >  public int prevSetBit(int index) {
> >    int i = index>>6;
> >    if (i >= wlen) {
> >      i = wlen - 1;
> >    }
> >    if (i < 0) return -1;
> >    final int subIndex = index & 0x3f;      // index within the word
> >    long word = (bits[i] << (63-subIndex));  // skip all the bits to
> > the left of index
> 
> And a further minor optimization, if we assume that negative indexes are
not
> legal, is to move the (i<0) check inside the if (i>=wlen) block (and just
let a
> negative index passed by the user to cause a natural AIOOB).
> 
> -Yonik
> http://www.lucidimagination.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected] For additional
> commands, e-mail: [email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to