@@ -132,6 +132,16 @@ bool LZXCodec<T>::forward(SliceArray<byte>& input, SliceArray<byte>& output, int
132
132
_hashes = new int32[_hashSize];
133
133
}
134
134
135
+ if (_bufferSize < max (count / 5 , 256 )) {
136
+ _bufferSize = max (count / 5 , 256 );
137
+ delete[] _mLenBuf;
138
+ _mLenBuf = new byte[_bufferSize];
139
+ delete[] _mBuf;
140
+ _mBuf = new byte[_bufferSize];
141
+ delete[] _tkBuf;
142
+ _tkBuf = new byte[_bufferSize];
143
+ }
144
+
135
145
memset (_hashes, 0 , sizeof (int32) * _hashSize);
136
146
const int srcEnd = count - 16 - 1 ;
137
147
const byte* src = &input._array [input._index ];
@@ -153,16 +163,6 @@ bool LZXCodec<T>::forward(SliceArray<byte>& input, SliceArray<byte>& output, int
153
163
}
154
164
}
155
165
156
- if (_bufferSize < max (count / 5 , 256 )) {
157
- _bufferSize = max (count / 5 , 256 );
158
- delete[] _mLenBuf;
159
- _mLenBuf = new byte[_bufferSize];
160
- delete[] _mBuf;
161
- _mBuf = new byte[_bufferSize];
162
- delete[] _tkBuf;
163
- _tkBuf = new byte[_bufferSize];
164
- }
165
-
166
166
const int minMatch = mm;
167
167
const int dThreshold = (maxDist == MAX_DISTANCE1) ? 1 << 8 : 1 << 16 ;
168
168
int srcIdx = 0 ;
@@ -208,7 +208,7 @@ bool LZXCodec<T>::forward(SliceArray<byte>& input, SliceArray<byte>& output, int
208
208
// No good match ?
209
209
if (bestLen < minMatch) {
210
210
srcIdx++;
211
- srcIdx += (srcInc >> 7 );
211
+ srcIdx += (srcInc >> 6 );
212
212
srcInc++;
213
213
repIdx = 0 ;
214
214
continue ;
@@ -356,7 +356,6 @@ bool LZXCodec<T>::forward(SliceArray<byte>& input, SliceArray<byte>& output, int
356
356
const int32 h = hash (&src[srcIdx]);
357
357
_hashes[h] = srcIdx;
358
358
}
359
-
360
359
}
361
360
362
361
// Emit last literals
@@ -388,7 +387,7 @@ bool LZXCodec<T>::forward(SliceArray<byte>& input, SliceArray<byte>& output, int
388
387
dstIdx += mLenIdx ;
389
388
input._index += count;
390
389
output._index += dstIdx;
391
- return true ;
390
+ return dstIdx <= count - (count / 100 ) ;
392
391
}
393
392
394
393
template <bool T>
@@ -480,6 +479,7 @@ bool LZXCodec<T>::inverse(SliceArray<byte>& input, SliceArray<byte>& output, int
480
479
mIdx += t;
481
480
}
482
481
482
+ prefetchRead (&src[mLenIdx ]);
483
483
repd1 = repd0;
484
484
repd0 = dist;
485
485
const int mEnd = dstIdx + mLen ;
@@ -491,7 +491,7 @@ bool LZXCodec<T>::inverse(SliceArray<byte>& input, SliceArray<byte>& output, int
491
491
goto exit;
492
492
}
493
493
494
- prefetchRead (&src[ mLenIdx ]);
494
+ prefetchWrite (&dst[dstIdx ]);
495
495
496
496
// Copy match
497
497
if (dist >= 16 ) {
@@ -575,6 +575,7 @@ bool LZPCodec::forward(SliceArray<byte>& input, SliceArray<byte>& output, int co
575
575
int dstIdx = 4 ;
576
576
577
577
while ((srcIdx < srcEnd - MIN_MATCH) && (dstIdx < dstEnd)) {
578
+ prefetchRead (&src[srcIdx + MIN_MATCH]);
578
579
const uint32 h = (HASH_SEED * ctx) >> HASH_SHIFT;
579
580
const int32 ref = _hashes[h];
580
581
_hashes[h] = srcIdx;
0 commit comments