MEM_INIT(cctx->hashTable, 0, LZ4_HASHTABLESIZE);
cctx->currentOffset = 0;
cctx->tableType = clearedTable;
+ } else {
+ DEBUGLOG(4, "Re-use hash table (no reset)");
+ //if (tableType == byU32) cctx->currentOffset += 64 KB;
}
}
- /* If the current offset is zero, we will never look in the external
- * dictionary context, since there is no value a table entry can take that
- * indicates a miss. In that case, we need to bump the offset to something
- * non-zero.
+
+ /* Adding a gap, so all previous entries are > MAX_DISTANCE back, is faster
+ * than compressing without a gap. However, compressing with
+ * currentOffset == 0 is faster still, so we preserve that case.
*/
- if (dictDirective == usingDictCtx &&
- tableType != byPtr &&
- cctx->currentOffset == 0)
- {
- cctx->currentOffset = 1;
+ if (cctx->currentOffset != 0 && tableType == byU32) {
+ cctx->currentOffset += 64 KB;
}
+
+ /* Finally, clear history */
+ cctx->dictCtx = NULL;
+ cctx->dictionary = NULL;
+ cctx->dictSize = 0;
}
/** LZ4_compress_generic() :
{
LZ4_stream_t_internal* ctx = &((LZ4_stream_t*)state)->internal_donotuse;
if (acceleration < 1) acceleration = ACCELERATION_DEFAULT;
- ctx->dictionary = NULL;
- ctx->dictSize = 0;
- ctx->dictCtx = NULL;
- if (maxOutputSize >= LZ4_compressBound(inputSize)) {
- if (inputSize < LZ4_64Klimit) {
+ if (dstCapacity >= LZ4_compressBound(srcSize)) {
+ if (srcSize < LZ4_64Klimit) {
const tableType_t tableType = byU16;
- LZ4_prepareTable(ctx, srcSize, tableType, noDict);
+ LZ4_prepareTable(ctx, inputSize, tableType);
++LZ4_prepareTable>>> dev
if (ctx->currentOffset) {
- return LZ4_compress_generic(ctx, source, dest, inputSize, 0, notLimited, tableType, noDict, dictSmall, acceleration);
+ return LZ4_compress_generic(ctx, src, dst, srcSize, 0, notLimited, tableType, noDict, dictSmall, acceleration);
} else {
- return LZ4_compress_generic(ctx, source, dest, inputSize, 0, notLimited, tableType, noDict, noDictIssue, acceleration);
+ return LZ4_compress_generic(ctx, src, dst, srcSize, 0, notLimited, tableType, noDict, noDictIssue, acceleration);
}
} else {
- const tableType_t tableType = ((sizeof(void*)==4) && ((uptrval)src > MAX_DISTANCE)) ? byPtr : byU32;
- LZ4_prepareTable(ctx, srcSize, tableType, noDict);
- if (ctx->currentOffset) {
- ctx->currentOffset += 64 KB;
- }
- return LZ4_compress_generic(ctx, src, dst, srcSize, 0, notLimited, tableType, noDict, noDictIssue, acceleration);
+ const tableType_t tableType = (sizeof(void*)==8) ? byU32 : byPtr;
+ LZ4_prepareTable(ctx, inputSize, tableType);
+ return LZ4_compress_generic(ctx, source, dest, inputSize, 0, notLimited, tableType, noDict, noDictIssue, acceleration);
}
} else {
- if (inputSize < LZ4_64Klimit) {
+ if (srcSize < LZ4_64Klimit) {
const tableType_t tableType = byU16;
- LZ4_prepareTable(ctx, srcSize, tableType, noDict);
+ LZ4_prepareTable(ctx, inputSize, tableType);
if (ctx->currentOffset) {
- return LZ4_compress_generic(ctx, source, dest, inputSize, maxOutputSize, limitedOutput, tableType, noDict, dictSmall, acceleration);
+ return LZ4_compress_generic(ctx, src, dst, srcSize, dstCapacity, limitedOutput, tableType, noDict, dictSmall, acceleration);
} else {
- return LZ4_compress_generic(ctx, source, dest, inputSize, maxOutputSize, limitedOutput, tableType, noDict, noDictIssue, acceleration);
+ return LZ4_compress_generic(ctx, src, dst, srcSize, dstCapacity, limitedOutput, tableType, noDict, noDictIssue, acceleration);
}
} else {
- const tableType_t tableType = ((sizeof(void*)==4) && ((uptrval)src > MAX_DISTANCE)) ? byPtr : byU32;
- LZ4_prepareTable(ctx, srcSize, tableType, noDict);
- if (ctx->currentOffset) {
- ctx->currentOffset += 64 KB;
- }
- return LZ4_compress_generic(ctx, src, dst, srcSize, dstCapacity, limitedOutput, tableType, noDict, noDictIssue, acceleration);
+ const tableType_t tableType = (sizeof(void*)==8) ? byU32 : byPtr;
+ LZ4_prepareTable(ctx, inputSize, tableType);
+ return LZ4_compress_generic(ctx, source, dest, inputSize, maxOutputSize, limitedOutput, tableType, noDict, noDictIssue, acceleration);
}
}
}