On Fri, Jun 24, 2011 at 1:35 PM, Uwe Schindler <u...@thetaphi.de> wrote: > Hi Yonik, I wrote atestcase that checks how prevSetBit behaves, if I add you > patch with optimization. It still had a bug, if the index is beyond last > word but not at a multiple of bitsPerWord.
Ahh, right, good catch! You want to start at the last bit rather than calculate the bit via MOD in that case. > Your additional optimization with negative indexes is invalid, Well, invalid if negative indexes are valid. > because on > negative indexes prevSetBit() must be negative. If we don’t do this, a > typical loop like would AIOOBE: > > for (int i = bs.prevSetBit(0); i >= 0; i = bs.prevSetBit(i-1)) { > // operate on index i here > } Yep, that makes sense to allow. -Yonik http://www.lucidimagination.com --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org For additional commands, e-mail: dev-h...@lucene.apache.org