ZSTD_ldm_adjustParameters(¶ms.ldmParams, ¶ms.cParams);
assert(params.ldmParams.hashLog >= params.ldmParams.bucketSizeLog);
assert(params.ldmParams.hashRateLog < 32);
- zc->ldmState.hashPower = ZSTD_rollingHash_primePower(params.ldmParams.minMatchLength);
}
{ size_t const windowSize = MAX(1, (size_t)MIN(((U64)1 << params.cParams.windowLog), pledgedSrcSize));
U32 checksum;
} ldmEntry_t;
+typedef struct {
+ BYTE const* split;
+ U32 hash;
+ U32 checksum;
+ ldmEntry_t* bucket;
+} ldmMatchCandidate_t;
+
+#define LDM_BATCH_SIZE 64
+
typedef struct {
ZSTD_window_t window; /* State for the window round buffer management */
ldmEntry_t* hashTable;
U32 loadedDictEnd;
BYTE* bucketOffsets; /* Next position in bucket to insert entry */
- U64 hashPower; /* Used to compute the rolling hash.
- * Depends on ldmParams.minMatchLength */
+ size_t splitIndices[LDM_BATCH_SIZE];
+ ldmMatchCandidate_t matchCandidates[LDM_BATCH_SIZE];
} ldmState_t;
typedef struct {
#define LDM_BUCKET_SIZE_LOG 3
#define LDM_MIN_MATCH_LENGTH 64
#define LDM_HASH_RLOG 7
-#define LDM_LOOKAHEAD_SPLITS 64
typedef struct {
U64 rolling;
*
* Registers in the splits array all the split points found in the first
* size bytes following the data pointer. This function terminates when
- * either all the data has been processed or LDM_LOOKAHEAD_SPLITS splits
- * are present in the splits array.
+ * either all the data has been processed or LDM_BATCH_SIZE splits are
+ * present in the splits array.
*
* Precondition: The splits array must not be full.
* Returns: The number of bytes processed. */
if (UNLIKELY((hash & mask) == 0)) { \
splits[*numSplits] = n; \
*numSplits += 1; \
- if (*numSplits == LDM_LOOKAHEAD_SPLITS) \
+ if (*numSplits == LDM_BATCH_SIZE) \
goto done; \
} \
} while (0)
BYTE const* const base = ldmState->window.base;
BYTE const* const istart = ip;
ldmRollingHashState_t hashState;
- size_t splits[LDM_LOOKAHEAD_SPLITS];
+ size_t* const splits = ldmState->splitIndices;
unsigned numSplits;
DEBUGLOG(5, "ZSTD_ldm_fillHashTable");
/* Rolling hash state */
ldmRollingHashState_t hashState;
/* Arrays for staged-processing */
- size_t splits[LDM_LOOKAHEAD_SPLITS];
- struct {
- BYTE const* split;
- U32 hash;
- U32 checksum;
- ldmEntry_t* bucket;
- } candidates[LDM_LOOKAHEAD_SPLITS];
+ size_t* const splits = ldmState->splitIndices;
+ ldmMatchCandidate_t* const candidates = ldmState->matchCandidates;
unsigned numSplits;
if (srcSize < minMatchLength)
ZSTD_ldm_adjustParameters(¶ms.ldmParams, ¶ms.cParams);
assert(params.ldmParams.hashLog >= params.ldmParams.bucketSizeLog);
assert(params.ldmParams.hashRateLog < 32);
- serialState->ldmState.hashPower =
- ZSTD_rollingHash_primePower(params.ldmParams.minMatchLength);
} else {
ZSTD_memset(¶ms.ldmParams, 0, sizeof(params.ldmParams));
}