|
|
e63c38 |
diff --git a/src/build/source_templates/compress.template b/src/build/source_templates/compress.template
|
|
|
e63c38 |
index 32008e9..09a5df4 100644
|
|
|
e63c38 |
--- a/src/build/source_templates/compress.template
|
|
|
e63c38 |
+++ b/src/build/source_templates/compress.template
|
|
|
e63c38 |
@@ -31,7 +31,6 @@
|
|
|
e63c38 |
main:
|
|
|
e63c38 |
while (true) {
|
|
|
e63c38 |
|
|
|
e63c38 |
- // find a match
|
|
|
e63c38 |
int forwardOff = sOff;
|
|
|
e63c38 |
|
|
|
e63c38 |
int ref;
|
|
|
e63c38 |
@@ -51,15 +50,12 @@
|
|
|
e63c38 |
${type}Utils.writeShort(hashTable, h, sOff - srcOff);
|
|
|
e63c38 |
} while (!LZ4${utils}.readIntEquals(src, ref, sOff));
|
|
|
e63c38 |
|
|
|
e63c38 |
- // catch up
|
|
|
e63c38 |
final int excess = LZ4${utils}.commonBytesBackward(src, ref, sOff, srcOff, anchor);
|
|
|
e63c38 |
sOff -= excess;
|
|
|
e63c38 |
ref -= excess;
|
|
|
e63c38 |
|
|
|
e63c38 |
- // sequence == refsequence
|
|
|
e63c38 |
final int runLen = sOff - anchor;
|
|
|
e63c38 |
|
|
|
e63c38 |
- // encode literal length
|
|
|
e63c38 |
int tokenOff = dOff++;
|
|
|
e63c38 |
|
|
|
e63c38 |
if (dOff + runLen + (2 + 1 + LAST_LITERALS) + (runLen >>> 8) > destEnd) {
|
|
|
e63c38 |
@@ -73,16 +69,13 @@
|
|
|
e63c38 |
${utils}.writeByte(dest, tokenOff, runLen << ML_BITS);
|
|
|
e63c38 |
}
|
|
|
e63c38 |
|
|
|
e63c38 |
- // copy literals
|
|
|
e63c38 |
LZ4${utils}.wildArraycopy(src, anchor, dest, dOff, runLen);
|
|
|
e63c38 |
dOff += runLen;
|
|
|
e63c38 |
|
|
|
e63c38 |
while (true) {
|
|
|
e63c38 |
- // encode offset
|
|
|
e63c38 |
${utils}.writeShortLE(dest, dOff, (short) (sOff - ref));
|
|
|
e63c38 |
dOff += 2;
|
|
|
e63c38 |
|
|
|
e63c38 |
- // count nb matches
|
|
|
e63c38 |
sOff += MIN_MATCH;
|
|
|
e63c38 |
ref += MIN_MATCH;
|
|
|
e63c38 |
final int matchLen = LZ4${utils}.commonBytes(src, ref, sOff, srcLimit);
|
|
|
e63c38 |
@@ -91,7 +84,6 @@
|
|
|
e63c38 |
}
|
|
|
e63c38 |
sOff += matchLen;
|
|
|
e63c38 |
|
|
|
e63c38 |
- // encode match len
|
|
|
e63c38 |
if (matchLen >= ML_MASK) {
|
|
|
e63c38 |
${utils}.writeByte(dest, tokenOff, ${utils}.readByte(dest, tokenOff) | ML_MASK);
|
|
|
e63c38 |
dOff = LZ4${utils}.writeLen(matchLen - ML_MASK, dest, dOff);
|
|
|
e63c38 |
@@ -99,16 +91,13 @@
|
|
|
e63c38 |
${utils}.writeByte(dest, tokenOff, ${utils}.readByte(dest, tokenOff) | matchLen);
|
|
|
e63c38 |
}
|
|
|
e63c38 |
|
|
|
e63c38 |
- // test end of chunk
|
|
|
e63c38 |
if (sOff > mflimit) {
|
|
|
e63c38 |
anchor = sOff;
|
|
|
e63c38 |
break main;
|
|
|
e63c38 |
}
|
|
|
e63c38 |
|
|
|
e63c38 |
- // fill table
|
|
|
e63c38 |
${type}Utils.writeShort(hashTable, hash64k(${utils}.readInt(src, sOff - 2)), sOff - 2 - srcOff);
|
|
|
e63c38 |
|
|
|
e63c38 |
- // test next position
|
|
|
e63c38 |
final int h = hash64k(${utils}.readInt(src, sOff));
|
|
|
e63c38 |
ref = srcOff + ${type}Utils.readShort(hashTable, h);
|
|
|
e63c38 |
${type}Utils.writeShort(hashTable, h, sOff - srcOff);
|
|
|
e63c38 |
@@ -121,7 +110,6 @@
|
|
|
e63c38 |
${utils}.writeByte(dest, tokenOff, 0);
|
|
|
e63c38 |
}
|
|
|
e63c38 |
|
|
|
e63c38 |
- // prepare next loop
|
|
|
e63c38 |
anchor = sOff++;
|
|
|
e63c38 |
}
|
|
|
e63c38 |
}
|
|
|
e63c38 |
@@ -160,7 +148,6 @@
|
|
|
e63c38 |
main:
|
|
|
e63c38 |
while (true) {
|
|
|
e63c38 |
|
|
|
e63c38 |
- // find a match
|
|
|
e63c38 |
int forwardOff = sOff;
|
|
|
e63c38 |
|
|
|
e63c38 |
int ref;
|
|
|
e63c38 |
@@ -187,10 +174,8 @@
|
|
|
e63c38 |
sOff -= excess;
|
|
|
e63c38 |
ref -= excess;
|
|
|
e63c38 |
|
|
|
e63c38 |
- // sequence == refsequence
|
|
|
e63c38 |
final int runLen = sOff - anchor;
|
|
|
e63c38 |
|
|
|
e63c38 |
- // encode literal length
|
|
|
e63c38 |
int tokenOff = dOff++;
|
|
|
e63c38 |
|
|
|
e63c38 |
if (dOff + runLen + (2 + 1 + LAST_LITERALS) + (runLen >>> 8) > destEnd) {
|
|
|
e63c38 |
@@ -204,16 +189,13 @@
|
|
|
e63c38 |
${utils}.writeByte(dest, tokenOff, runLen << ML_BITS);
|
|
|
e63c38 |
}
|
|
|
e63c38 |
|
|
|
e63c38 |
- // copy literals
|
|
|
e63c38 |
LZ4${utils}.wildArraycopy(src, anchor, dest, dOff, runLen);
|
|
|
e63c38 |
dOff += runLen;
|
|
|
e63c38 |
|
|
|
e63c38 |
while (true) {
|
|
|
e63c38 |
- // encode offset
|
|
|
e63c38 |
${utils}.writeShortLE(dest, dOff, back);
|
|
|
e63c38 |
dOff += 2;
|
|
|
e63c38 |
|
|
|
e63c38 |
- // count nb matches
|
|
|
e63c38 |
sOff += MIN_MATCH;
|
|
|
e63c38 |
final int matchLen = LZ4${utils}.commonBytes(src, ref + MIN_MATCH, sOff, srcLimit);
|
|
|
e63c38 |
if (dOff + (1 + LAST_LITERALS) + (matchLen >>> 8) > destEnd) {
|
|
|
e63c38 |
@@ -221,7 +203,6 @@
|
|
|
e63c38 |
}
|
|
|
e63c38 |
sOff += matchLen;
|
|
|
e63c38 |
|
|
|
e63c38 |
- // encode match len
|
|
|
e63c38 |
if (matchLen >= ML_MASK) {
|
|
|
e63c38 |
${utils}.writeByte(dest, tokenOff, ${utils}.readByte(dest, tokenOff) | ML_MASK);
|
|
|
e63c38 |
dOff = LZ4${utils}.writeLen(matchLen - ML_MASK, dest, dOff);
|
|
|
e63c38 |
@@ -229,16 +210,13 @@
|
|
|
e63c38 |
${utils}.writeByte(dest, tokenOff, ${utils}.readByte(dest, tokenOff) | matchLen);
|
|
|
e63c38 |
}
|
|
|
e63c38 |
|
|
|
e63c38 |
- // test end of chunk
|
|
|
e63c38 |
if (sOff > mflimit) {
|
|
|
e63c38 |
anchor = sOff;
|
|
|
e63c38 |
break main;
|
|
|
e63c38 |
}
|
|
|
e63c38 |
|
|
|
e63c38 |
- // fill table
|
|
|
e63c38 |
${type}Utils.writeInt(hashTable, hash(${utils}.readInt(src, sOff - 2)), sOff - 2);
|
|
|
e63c38 |
|
|
|
e63c38 |
- // test next position
|
|
|
e63c38 |
final int h = hash(${utils}.readInt(src, sOff));
|
|
|
e63c38 |
ref = ${type}Utils.readInt(hashTable, h);
|
|
|
e63c38 |
${type}Utils.writeInt(hashTable, h, sOff);
|
|
|
e63c38 |
@@ -252,7 +230,6 @@
|
|
|
e63c38 |
${utils}.writeByte(dest, tokenOff, 0);
|
|
|
e63c38 |
}
|
|
|
e63c38 |
|
|
|
e63c38 |
- // prepare next loop
|
|
|
e63c38 |
anchor = sOff++;
|
|
|
e63c38 |
}
|
|
|
e63c38 |
|
|
|
e63c38 |
diff --git a/src/build/source_templates/compress_hc.template b/src/build/source_templates/compress_hc.template
|
|
|
e63c38 |
index 7179db3..7976ad1 100644
|
|
|
e63c38 |
--- a/src/build/source_templates/compress_hc.template
|
|
|
e63c38 |
+++ b/src/build/source_templates/compress_hc.template
|
|
|
e63c38 |
@@ -47,7 +47,6 @@
|
|
|
e63c38 |
continue;
|
|
|
e63c38 |
}
|
|
|
e63c38 |
|
|
|
e63c38 |
- // saved, in case we would skip too much
|
|
|
e63c38 |
copyTo(match1, match0);
|
|
|
e63c38 |
|
|
|
e63c38 |
search2:
|
|
|
e63c38 |
@@ -55,20 +54,19 @@
|
|
|
e63c38 |
assert match1.start >= anchor;
|
|
|
e63c38 |
if (match1.end() >= mfLimit
|
|
|
e63c38 |
|| !ht.insertAndFindWiderMatch(src, match1.end() - 2, match1.start + 1, matchLimit, match1.len, match2)) {
|
|
|
e63c38 |
- // no better match
|
|
|
e63c38 |
dOff = LZ4${utils}.encodeSequence(src, anchor, match1.start, match1.ref, match1.len, dest, dOff, destEnd);
|
|
|
e63c38 |
anchor = sOff = match1.end();
|
|
|
e63c38 |
continue main;
|
|
|
e63c38 |
}
|
|
|
e63c38 |
|
|
|
e63c38 |
if (match0.start < match1.start) {
|
|
|
e63c38 |
- if (match2.start < match1.start + match0.len) { // empirical
|
|
|
e63c38 |
+ if (match2.start < match1.start + match0.len) {
|
|
|
e63c38 |
copyTo(match0, match1);
|
|
|
e63c38 |
}
|
|
|
e63c38 |
}
|
|
|
e63c38 |
assert match2.start > match1.start;
|
|
|
e63c38 |
|
|
|
e63c38 |
- if (match2.start - match1.start < 3) { // First Match too small : removed
|
|
|
e63c38 |
+ if (match2.start - match1.start < 3) {
|
|
|
e63c38 |
copyTo(match2, match1);
|
|
|
e63c38 |
continue search2;
|
|
|
e63c38 |
}
|
|
|
e63c38 |
@@ -91,21 +89,18 @@
|
|
|
e63c38 |
|
|
|
e63c38 |
if (match2.start + match2.len >= mfLimit
|
|
|
e63c38 |
|| !ht.insertAndFindWiderMatch(src, match2.end() - 3, match2.start, matchLimit, match2.len, match3)) {
|
|
|
e63c38 |
- // no better match -> 2 sequences to encode
|
|
|
e63c38 |
if (match2.start < match1.end()) {
|
|
|
e63c38 |
match1.len = match2.start - match1.start;
|
|
|
e63c38 |
}
|
|
|
e63c38 |
- // encode seq 1
|
|
|
e63c38 |
dOff = LZ4${utils}.encodeSequence(src, anchor, match1.start, match1.ref, match1.len, dest, dOff, destEnd);
|
|
|
e63c38 |
anchor = sOff = match1.end();
|
|
|
e63c38 |
- // encode seq 2
|
|
|
e63c38 |
dOff = LZ4${utils}.encodeSequence(src, anchor, match2.start, match2.ref, match2.len, dest, dOff, destEnd);
|
|
|
e63c38 |
anchor = sOff = match2.end();
|
|
|
e63c38 |
continue main;
|
|
|
e63c38 |
}
|
|
|
e63c38 |
|
|
|
e63c38 |
- if (match3.start < match1.end() + 3) { // Not enough space for match 2 : remove it
|
|
|
e63c38 |
- if (match3.start >= match1.end()) { // // can write Seq1 immediately ==> Seq2 is removed, so Seq3 becomes Seq1
|
|
|
e63c38 |
+ if (match3.start < match1.end() + 3) {
|
|
|
e63c38 |
+ if (match3.start >= match1.end()) {
|
|
|
e63c38 |
if (match2.start < match1.end()) {
|
|
|
e63c38 |
final int correction = match1.end() - match2.start;
|
|
|
e63c38 |
match2.fix(correction);
|
|
|
e63c38 |
@@ -127,7 +122,6 @@
|
|
|
e63c38 |
continue search3;
|
|
|
e63c38 |
}
|
|
|
e63c38 |
|
|
|
e63c38 |
- // OK, now we have 3 ascending matches; let's write at least the first one
|
|
|
e63c38 |
if (match2.start < match1.end()) {
|
|
|
e63c38 |
if (match2.start - match1.start < ML_MASK) {
|
|
|
e63c38 |
if (match1.len > OPTIMAL_ML) {
|
|
|
e63c38 |
diff --git a/src/build/source_templates/decompress.template b/src/build/source_templates/decompress.template
|
|
|
e63c38 |
index f1c2890..1e2aa23 100644
|
|
|
e63c38 |
--- a/src/build/source_templates/decompress.template
|
|
|
e63c38 |
+++ b/src/build/source_templates/decompress.template
|
|
|
e63c38 |
@@ -55,7 +55,6 @@
|
|
|
e63c38 |
final int token = ${utils}.readByte(src, sOff) & 0xFF;
|
|
|
e63c38 |
++sOff;
|
|
|
e63c38 |
|
|
|
e63c38 |
- // literals
|
|
|
e63c38 |
int literalLen = token >>> ML_BITS;
|
|
|
e63c38 |
if (literalLen == RUN_MASK) {
|
|
|
e63c38 |
byte len = (byte) 0xFF;
|
|
|
e63c38 |
@@ -81,7 +80,7 @@
|
|
|
e63c38 |
LZ4${utils}.safeArraycopy(src, sOff, dest, dOff, literalLen);
|
|
|
e63c38 |
sOff += literalLen;
|
|
|
e63c38 |
dOff = literalCopyEnd;
|
|
|
e63c38 |
- break; // EOF
|
|
|
e63c38 |
+ break;
|
|
|
e63c38 |
}
|
|
|
e63c38 |
}
|
|
|
e63c38 |
|
|
|
e63c38 |
@@ -89,7 +88,6 @@
|
|
|
e63c38 |
sOff += literalLen;
|
|
|
e63c38 |
dOff = literalCopyEnd;
|
|
|
e63c38 |
|
|
|
e63c38 |
- // matchs
|
|
|
e63c38 |
final int matchDec = ${utils}.readShortLE(src, sOff);
|
|
|
e63c38 |
sOff += 2;
|
|
|
e63c38 |
int matchOff = dOff - matchDec;
|
|
|
e63c38 |
diff --git a/src/build/source_templates/hashtable.template b/src/build/source_templates/hashtable.template
|
|
|
e63c38 |
index 174f8e8..91935f5 100644
|
|
|
e63c38 |
--- a/src/build/source_templates/hashtable.template
|
|
|
e63c38 |
+++ b/src/build/source_templates/hashtable.template
|
|
|
e63c38 |
@@ -92,8 +92,8 @@
|
|
|
e63c38 |
|
|
|
e63c38 |
int ref = hashPointer(buf, off);
|
|
|
e63c38 |
|
|
|
e63c38 |
- if (ref >= off - 4 && ref <= off && ref >= base) { // potential repetition
|
|
|
e63c38 |
- if (LZ4${utils}.readIntEquals(buf, ref, off)) { // confirmed
|
|
|
e63c38 |
+ if (ref >= off - 4 && ref <= off && ref >= base) {
|
|
|
e63c38 |
+ if (LZ4${utils}.readIntEquals(buf, ref, off)) {
|
|
|
e63c38 |
delta = off - ref;
|
|
|
e63c38 |
repl = match.len = MIN_MATCH + LZ4${utils}.commonBytes(buf, ref + MIN_MATCH, off + MIN_MATCH, matchLimit);
|
|
|
e63c38 |
match.ref = ref;
|
|
|
e63c38 |
@@ -119,7 +119,7 @@
|
|
|
e63c38 |
int ptr = off;
|
|
|
e63c38 |
final int end = off + repl - (MIN_MATCH - 1);
|
|
|
e63c38 |
while (ptr < end - delta) {
|
|
|
e63c38 |
- chainTable[ptr & MASK] = (short) delta; // pre load
|
|
|
e63c38 |
+ chainTable[ptr & MASK] = (short) delta;
|
|
|
e63c38 |
++ptr;
|
|
|
e63c38 |
}
|
|
|
e63c38 |
do {
|
|
|
e63c38 |
diff --git a/src/build/source_templates/xxhash32_streaming.template b/src/build/source_templates/xxhash32_streaming.template
|
|
|
e63c38 |
index 6166758..9fa55e8 100644
|
|
|
e63c38 |
--- a/src/build/source_templates/xxhash32_streaming.template
|
|
|
e63c38 |
+++ b/src/build/source_templates/xxhash32_streaming.template
|
|
|
e63c38 |
@@ -66,7 +66,7 @@ final class StreamingXXHash32Java${type} extends AbstractStreamingXXHash32Java {
|
|
|
e63c38 |
|
|
|
e63c38 |
totalLen += len;
|
|
|
e63c38 |
|
|
|
e63c38 |
- if (memSize + len < 16) { // fill in tmp buffer
|
|
|
e63c38 |
+ if (memSize + len < 16) {
|
|
|
e63c38 |
System.arraycopy(buf, off, memory, memSize, len);
|
|
|
e63c38 |
memSize += len;
|
|
|
e63c38 |
return;
|
|
|
e63c38 |
@@ -74,7 +74,7 @@ final class StreamingXXHash32Java${type} extends AbstractStreamingXXHash32Java {
|
|
|
e63c38 |
|
|
|
e63c38 |
final int end = off + len;
|
|
|
e63c38 |
|
|
|
e63c38 |
- if (memSize > 0) { // data left from previous update
|
|
|
e63c38 |
+ if (memSize > 0) {
|
|
|
e63c38 |
System.arraycopy(buf, off, memory, memSize, 16 - memSize);
|
|
|
e63c38 |
|
|
|
e63c38 |
v1 += readIntLE(memory, 0) * PRIME2;
|
|
|
e63c38 |
diff --git a/src/build/source_templates/xxhash64_streaming.template b/src/build/source_templates/xxhash64_streaming.template
|
|
|
e63c38 |
index 2789ae0..e781746 100644
|
|
|
e63c38 |
--- a/src/build/source_templates/xxhash64_streaming.template
|
|
|
e63c38 |
+++ b/src/build/source_templates/xxhash64_streaming.template
|
|
|
e63c38 |
@@ -90,7 +90,7 @@ final class StreamingXXHash64Java${type} extends AbstractStreamingXXHash64Java {
|
|
|
e63c38 |
|
|
|
e63c38 |
totalLen += len;
|
|
|
e63c38 |
|
|
|
e63c38 |
- if (memSize + len < 32) { // fill in tmp buffer
|
|
|
e63c38 |
+ if (memSize + len < 32) {
|
|
|
e63c38 |
System.arraycopy(buf, off, memory, memSize, len);
|
|
|
e63c38 |
memSize += len;
|
|
|
e63c38 |
return;
|
|
|
e63c38 |
@@ -98,7 +98,7 @@ final class StreamingXXHash64Java${type} extends AbstractStreamingXXHash64Java {
|
|
|
e63c38 |
|
|
|
e63c38 |
final int end = off + len;
|
|
|
e63c38 |
|
|
|
e63c38 |
- if (memSize > 0) { // data left from previous update
|
|
|
e63c38 |
+ if (memSize > 0) {
|
|
|
e63c38 |
System.arraycopy(buf, off, memory, memSize, 32 - memSize);
|
|
|
e63c38 |
|
|
|
e63c38 |
v1 += readLongLE(memory, 0) * PRIME64_2;
|