moved ctx->end handling from parsers
authorYann Collet <cyan@fb.com>
Fri, 3 Nov 2017 17:48:55 +0000 (10:48 -0700)
committerYann Collet <cyan@fb.com>
Fri, 3 Nov 2017 17:48:55 +0000 (10:48 -0700)
responsibility better handled one layer above (LZ4HC_compress_generic())

lib/lz4hc.c
lib/lz4opt.h

index a7577c5..cea83f2 100644 (file)
@@ -457,7 +457,6 @@ static int LZ4HC_compress_hashChain (
     if (limit == limitedDestSize && maxOutputSize < 1) return 0;         /* Impossible to store anything */
     if ((U32)inputSize > (U32)LZ4_MAX_INPUT_SIZE) return 0;              /* Unsupported input size, too large (or negative) */
 
-    ctx->end += inputSize;
     if (limit == limitedDestSize) oend -= LASTLITERALS;                  /* Hack for support limitations LZ4 decompressor */
     if (inputSize < LZ4_minLength) goto _last_literals;                  /* Input too small, no compression (all literals) */
 
@@ -651,7 +650,8 @@ static int LZ4HC_compress_generic (
     limitedOutput_directive limit
     )
 {
-    if (cLevel < 1) cLevel = LZ4HC_CLEVEL_DEFAULT;   /* note : convention is different from lz4frame, maybe to reconsider */
+    ctx->end += *srcSizePtr;
+    if (cLevel < 1) cLevel = LZ4HC_CLEVEL_DEFAULT;   /* note : convention is different from lz4frame, maybe something to review */
     if (cLevel > 9) {
         if (limit == limitedDestSize) cLevel = 10;
         switch (cLevel) {
index 7aec7dd..df8ecd6 100644 (file)
@@ -128,7 +128,6 @@ static int LZ4HC_compress_optimal (
     /* init */
     DEBUGLOG(5, "LZ4HC_compress_optimal");
     if (sufficient_len >= LZ4_OPT_NUM) sufficient_len = LZ4_OPT_NUM-1;
-    ctx->end += inputSize;
     ip++;
 
     /* Main Loop */