Merge branch 'dev' into lowAddr
authortest4973 <Kdo4973@hotmail.com>
Wed, 11 Apr 2018 23:45:19 +0000 (16:45 -0700)
committertest4973 <Kdo4973@hotmail.com>
Wed, 11 Apr 2018 23:45:19 +0000 (16:45 -0700)
1  2 
lib/lz4.c

diff --cc lib/lz4.c
+++ b/lib/lz4.c
@@@ -593,22 -566,21 +592,24 @@@ LZ4_FORCE_INLINE void LZ4_prepareTable
              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() :
@@@ -955,43 -860,34 +957,35 @@@ int LZ4_compress_fast_extState_fastRese
  {
      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);
          }
      }
  }