Skip to content

Commit be9e643

Browse files
committed
Tweak code
1 parent 0e5a980 commit be9e643

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

src/transform/LZCodec.cpp

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ bool LZCodec::inverse(SliceArray<byte>& input, SliceArray<byte>& output, int cou
6767
template<>
6868
const uint LZXCodec<false>::HASH_SEED = 0x1E35A7BD;
6969
template<>
70-
const uint LZXCodec<false>::HASH_LOG = 15;
70+
const uint LZXCodec<false>::HASH_LOG = 16;
7171
template<>
7272
const uint LZXCodec<false>::HASH_RSHIFT = 64 - HASH_LOG;
7373
template<>
@@ -391,24 +391,22 @@ bool LZXCodec<T>::forward(SliceArray<byte>& input, SliceArray<byte>& output, int
391391
anchor = srcIdx + bestLen;
392392
prefetchRead(&src[anchor + 64]);
393393
prefetchRead(&src[anchor + 128]);
394-
srcIdx++;
395394

396395
while (srcIdx + 4 < anchor) {
397-
const int32 h0 = hash(&src[srcIdx + 0]);
398-
const int32 h1 = hash(&src[srcIdx + 1]);
399-
const int32 h2 = hash(&src[srcIdx + 2]);
400-
const int32 h3 = hash(&src[srcIdx + 3]);
401-
_hashes[h0] = srcIdx + 0;
402-
_hashes[h1] = srcIdx + 1;
403-
_hashes[h2] = srcIdx + 2;
404-
_hashes[h3] = srcIdx + 3;
405396
srcIdx += 4;
397+
const int32 h0 = hash(&src[srcIdx - 3]);
398+
const int32 h1 = hash(&src[srcIdx - 2]);
399+
const int32 h2 = hash(&src[srcIdx - 1]);
400+
const int32 h3 = hash(&src[srcIdx - 0]);
401+
_hashes[h0] = srcIdx - 3;
402+
_hashes[h1] = srcIdx - 2;
403+
_hashes[h2] = srcIdx - 1;
404+
_hashes[h3] = srcIdx - 0;
406405
}
407406

408-
while (srcIdx < anchor) {
407+
while (++srcIdx < anchor) {
409408
const int32 h = hash(&src[srcIdx]);
410409
_hashes[h] = srcIdx;
411-
srcIdx++;
412410
}
413411
}
414412

0 commit comments

Comments
 (0)