diff options
author | W. Felix Handte <w@felixhandte.com> | 2018-03-09 17:14:42 (GMT) |
---|---|---|
committer | W. Felix Handte <w@felixhandte.com> | 2018-03-12 18:58:43 (GMT) |
commit | 5f8967b98364629310d0013b356070ab445f9e66 (patch) | |
tree | 4078afc24356755bd24367dd33b761a3e2b77165 | |
parent | 6716325ae8db3f177630c875622401e35e4a84e5 (diff) | |
download | lz4-5f8967b98364629310d0013b356070ab445f9e66.zip lz4-5f8967b98364629310d0013b356070ab445f9e66.tar.gz lz4-5f8967b98364629310d0013b356070ab445f9e66.tar.bz2 |
Specialize _extState() for Clean Ctx Rather Than Calling _safeExtState()
-rw-r--r-- | lib/lz4.c | 24 |
1 files changed, 19 insertions, 5 deletions
@@ -805,8 +805,24 @@ _clean_up: int LZ4_compress_fast_extState(void* state, const char* source, char* dest, int inputSize, int maxOutputSize, int acceleration) { - LZ4_resetStream((LZ4_stream_t*)state); - return LZ4_compress_fast_safeExtState(state, source, dest, inputSize, maxOutputSize, acceleration); + LZ4_stream_t_internal* ctx = &((LZ4_stream_t*)state)->internal_donotuse; + if (acceleration < 1) acceleration = ACCELERATION_DEFAULT; + LZ4_resetStream((LZ4_stream_t*)state); + if (maxOutputSize >= LZ4_compressBound(inputSize)) { + if (inputSize < LZ4_64Klimit) { + return LZ4_compress_generic(ctx, source, dest, inputSize, 0, notLimited, byU16, noDict, noDictIssue, acceleration); + } else { + const tableType_t tableType = (sizeof(void*)==8) ? byU32 : byPtr; + return LZ4_compress_generic(ctx, source, dest, inputSize, 0, notLimited, tableType, noDict, noDictIssue, acceleration); + } + } else { + if (inputSize < LZ4_64Klimit) {; + return LZ4_compress_generic(ctx, source, dest, inputSize, maxOutputSize, limitedOutput, byU16, noDict, noDictIssue, acceleration); + } else { + const tableType_t tableType = (sizeof(void*)==8) ? byU32 : byPtr; + return LZ4_compress_generic(ctx, source, dest, inputSize, maxOutputSize, limitedOutput, tableType, noDict, noDictIssue, acceleration); + } + } } @@ -861,9 +877,7 @@ int LZ4_compress_fast(const char* source, char* dest, int inputSize, int maxOutp LZ4_stream_t ctx; LZ4_stream_t* const ctxPtr = &ctx; #endif - ctxPtr->internal_donotuse.initCheck = 0; - ctxPtr->internal_donotuse.tableType = byPtr; /* always triggers a reset */ - result = LZ4_compress_fast_safeExtState(ctxPtr, source, dest, inputSize, maxOutputSize, acceleration); + result = LZ4_compress_fast_extState(ctxPtr, source, dest, inputSize, maxOutputSize, acceleration); #if (LZ4_HEAPMODE) FREEMEM(ctxPtr); |