LUCENE-6009: Remove redundant == NO_MORE_DOCS checks.

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1632314 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Adrien Grand 2014-10-16 14:01:53 +00:00
parent e1b7594cd0
commit 6697abbb28
4 changed files with 12 additions and 45 deletions

View File

@ -59,24 +59,7 @@ public final class FixedBitSet extends DocIdSet implements MutableBits {
@Override
public int nextDoc() {
if (doc == NO_MORE_DOCS || ++doc >= numBits) {
return doc = NO_MORE_DOCS;
}
int i = doc >> 6;
long word = bits[i] >> doc; // skip all the bits to the right of index
if (word != 0) {
return doc = doc + Long.numberOfTrailingZeros(word);
}
while (++i < numWords) {
word = bits[i];
if (word != 0) {
return doc = (i << 6) + Long.numberOfTrailingZeros(word);
}
}
return doc = NO_MORE_DOCS;
return advance(doc + 1);
}
@Override
@ -91,7 +74,7 @@ public final class FixedBitSet extends DocIdSet implements MutableBits {
@Override
public int advance(int target) {
if (doc == NO_MORE_DOCS || target >= numBits) {
if (target >= numBits) {
return doc = NO_MORE_DOCS;
}
int i = target >> 6;

View File

@ -82,9 +82,6 @@ public final class NotDocIdSet extends DocIdSet {
@Override
public int nextDoc() throws IOException {
if (doc == NO_MORE_DOCS) {
return NO_MORE_DOCS;
}
return advance(doc + 1);
}

View File

@ -282,9 +282,6 @@ public class RoaringDocIdSet extends DocIdSet {
@Override
public int nextDoc() throws IOException {
if (doc == NO_MORE_DOCS) {
return NO_MORE_DOCS;
}
final int subNext = sub.nextDoc();
if (subNext == NO_MORE_DOCS) {
return firstDocFromNextBlock();

View File

@ -248,16 +248,17 @@ public class SparseFixedBitSet extends DocIdSet implements Bits {
@Override
public int nextDoc() throws IOException {
if (++doc >= length) {
return doc = NO_MORE_DOCS;
}
return currentOrNextDoc();
return advance(doc + 1);
}
private int currentOrNextDoc() {
final int i4096 = doc >>> 12;
@Override
public int advance(int target) throws IOException {
final int i4096 = target >>> 12;
if (i4096 >= indices.length) {
return doc = NO_MORE_DOCS;
}
final long index = indices[i4096];
int i64 = doc >>> 6;
int i64 = target >>> 6;
long indexBits = index >>> i64;
if (indexBits == 0) {
// if the index is zero, it means that there is no value in the
@ -270,7 +271,7 @@ public class SparseFixedBitSet extends DocIdSet implements Bits {
} else {
// We know we still have some 64-bits blocks that have bits set, let's
// advance to the next one by skipping trailing zeros of the index
int i1 = doc & 0x3F;
int i1 = target & 0x3F;
int trailingZeros = Long.numberOfTrailingZeros(indexBits);
if (trailingZeros != 0) {
// no bits in the current long, go to the next one
@ -285,7 +286,7 @@ public class SparseFixedBitSet extends DocIdSet implements Bits {
int longIndex = Long.bitCount(index & ((1L << i64) - 1)); // shifts are mod 64 in java
final long[] longArray = bits[i4096];
assert longArray[longIndex] != 0;
long bits = SparseFixedBitSet.this.bits[i4096][longIndex] >>> i1; // shifts are mod 64 in java
long bits = longArray[longIndex] >>> i1; // shifts are mod 64 in java
if (bits != 0L) {
// hurray, we found some non-zero bits, this gives us the next document:
i1 += Long.numberOfTrailingZeros(bits);
@ -312,17 +313,6 @@ public class SparseFixedBitSet extends DocIdSet implements Bits {
}
}
@Override
public int advance(int target) throws IOException {
if (target >= length) {
return doc = NO_MORE_DOCS;
} else {
doc = target;
}
return currentOrNextDoc();
}
@Override
public long cost() {
// although constant-time, approximateCardinality is a bit expensive so