mirror of https://github.com/apache/lucene.git
Quick exit for non-zero slice buffers (#12812)
This commit is contained in:
parent
18a6033a7e
commit
1c4c1c831d
|
@ -178,6 +178,8 @@ Improvements
|
|||
|
||||
* GITHUB#12870: Tighten synchronized loop in DirectoryTaxonomyReader#getOrdinal. (Stefan Vodita)
|
||||
|
||||
* GITHUB#12812: Avoid overflows and false negatives in int slice buffer filled-with-zeros assertion. (Stefan Vodita)
|
||||
|
||||
Optimizations
|
||||
---------------------
|
||||
(No changes)
|
||||
|
|
|
@ -179,6 +179,19 @@ public class MemoryIndex {
|
|||
super(allocator);
|
||||
}
|
||||
|
||||
/**
|
||||
* For slices, buffers must be filled with zeros, so that we can find a slice's end based on a
|
||||
* non-zero final value.
|
||||
*/
|
||||
private static boolean assertSliceBuffer(int[] buffer) {
|
||||
for (int value : buffer) {
|
||||
if (value != 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new int slice with the given starting size and returns the slices offset in the
|
||||
* pool.
|
||||
|
@ -197,14 +210,6 @@ public class MemoryIndex {
|
|||
return upto;
|
||||
}
|
||||
|
||||
private static boolean assertSliceBuffer(int[] buffer) {
|
||||
int count = 0;
|
||||
for (int i = 0; i < buffer.length; i++) {
|
||||
count += buffer[i]; // for slices the buffer must only have 0 values
|
||||
}
|
||||
return count == 0;
|
||||
}
|
||||
|
||||
/** Allocates a new slice from the given offset */
|
||||
private int allocSlice(final int[] slice, final int sliceOffset) {
|
||||
final int level = slice[sliceOffset] & 15;
|
||||
|
|
Loading…
Reference in New Issue