added assert
authorYann Collet <cyan@fb.com>
Thu, 19 Oct 2017 23:47:25 +0000 (16:47 -0700)
committerYann Collet <cyan@fb.com>
Thu, 19 Oct 2017 23:47:25 +0000 (16:47 -0700)
lib/lz4.c
lib/lz4opt.h

index 19967f2..016e5c7 100644 (file)
--- a/lib/lz4.c
+++ b/lib/lz4.c
@@ -289,6 +289,14 @@ static const int LZ4_minLength = (MFLIMIT+1);
 /*-************************************
 *  Error detection
 **************************************/
+#if defined(LZ4_DEBUG) && (LZ4_DEBUG>=1)
+#  include <assert.h>
+#else
+#  ifndef assert
+#    define assert(condition) ((void)0)
+#  endif
+#endif
+
 #define LZ4_STATIC_ASSERT(c)   { enum { LZ4_static_assert = 1/(int)(!!(c)) }; }   /* use only *after* variable declarations */
 
 #if defined(LZ4_DEBUG) && (LZ4_DEBUG>=2)
index e6a748c..69c48dc 100644 (file)
@@ -262,7 +262,7 @@ static int LZ4HC_compress_optimal (
                     SET_PRICE(mlen, mlen, matches[matchNb].off, 0, cost);   /* updates last_match_pos and opt[pos] */
         }   }   }
 
-        if (last_match_pos < MINMATCH) { ip++; continue; }  /* note : on clang at least, this test improves performance */
+        assert(last_match_pos >= MINMATCH);
 
         /* check further positions */
         opt[0].mlen = opt[1].mlen = 1;