final CRC32 crc32 = new CRC32();
crc32.update(memory.array(), memory.position(), length);
- // If the stored checksum equals the computed checksum, return the entry.
- if (checksum == crc32.getValue()) {
- int limit = memory.limit();
- memory.limit(memory.position() + length);
- final E entry = namespace.deserialize(memory);
- memory.limit(limit);
- lastEntry = new Indexed<>(nextIndex, entry, length);
- this.index.index(nextIndex, (int) position);
- nextIndex++;
- } else {
+ // If the stored checksum does not equal the computed checksum, do not proceed further
+ if (checksum != crc32.getValue()) {
break;
}
+ int limit = memory.limit();
+ memory.limit(memory.position() + length);
+ final E entry = namespace.deserialize(memory);
+ memory.limit(limit);
+ lastEntry = new Indexed<>(nextIndex, entry, length);
+ this.index.index(nextIndex, (int) position);
+ nextIndex++;
+
// Update the current position for indexing.
position = channel.position() + memory.position();
slice.limit(length);
crc32.update(slice);
- // If the stored checksum equals the computed checksum, return the entry.
- if (checksum == crc32.getValue()) {
- slice.rewind();
- final E entry = namespace.deserialize(slice);
- lastEntry = new Indexed<>(nextIndex, entry, length);
- this.index.index(nextIndex, position);
- nextIndex++;
- } else {
+ // If the stored checksum does not equal the computed checksum, do not proceed further
+ if (checksum != crc32.getValue()) {
break;
}
+ slice.rewind();
+ final E entry = namespace.deserialize(slice);
+ lastEntry = new Indexed<>(nextIndex, entry, length);
+ this.index.index(nextIndex, position);
+ nextIndex++;
+
// Update the current position for indexing.
position = buffer.position() + length;
buffer.position(position);