#define ZSTD_OPT_NUM (1<<12)
#define ZSTD_FREQ_THRESHOLD (256)
+
+// log2_32 is from http://stackoverflow.com/questions/11376288/fast-computing-of-log2-for-64-bit-integers
const int tab32[32] = {
0, 9, 1, 10, 13, 21, 2, 29,
11, 14, 16, 18, 22, 25, 3, 30,
match = base + matchIndex;
if (match[minml] == ip[minml]) /* potentially better */
currentMl = ZSTD_count(ip, match, iHighLimit);
-#if 0
- const BYTE* start = ip;
- size_t offset = current - matchIndex;
- while ((start > iLowLimit) && (start > base+offset) && (start[-1] == start[-1-offset])) start--;
- back = ip - start;
-#else
- // while ((match-back > base) && (ip-back > iLowLimit) && (ip[-back-1] == match[-back-1])) back++;
-#endif
- currentMl += back;
+
+ if (currentMl > 0) {
+ while ((match-back > base) && (ip-back > iLowLimit) && (ip[-back-1] == match[-back-1])) back++; /* backward match extension */
+ currentMl += back;
+ }
} else {
match = dictBase + matchIndex;
if (MEM_read32(match) == MEM_read32(ip)) /* assumption : matchIndex <= dictLimit-4 (by table construction) */
goto _storeSequence;
}
+
// set prices using matches at position = cur
for (int i = 0; i < match_num; i++)
{
// printf("match="); print_hex_text(ip-offset, mlen, 0);
#if ZSTD_OPT_DEBUG >= 5
- size_t ml2;
+ int ml2;
if (offset)
ml2 = ZSTD_count(ip, ip-offset, iend);
else