lz4-java
lz4-java copied to clipboard
Double copying in LZ4UnsafeUtils.safeIncrementalCopy
Here the line which safely copies a byte is followed by a line which unsafely copies the byte:
static void safeIncrementalCopy(byte[] dest, int matchOff, int dOff, int matchLen) {
for (int i = 0; i < matchLen; ++i) {
dest[dOff + i] = dest[matchOff + i];
writeByte(dest, dOff + i, readByte(dest, matchOff + i));
}
}
I have measured the impact of deleting one line or the other; the clear winner is the simple Java idiom: dest[dOff + i] = dest[matchOff + i]; My measurement on data which is a simple repetition of byte values 0, 1, 2, ..., 255 shows very poor peformance with the 1.3 release version of LZ4 Unsafe decompressor; this one change (deleting writeBytes above) doubles the performance.