]> git.saurik.com Git - redis.git/commitdiff
Compare integers in ziplist regardless of encoding
authorPieter Noordhuis <pcnoordhuis@gmail.com>
Sat, 5 May 2012 00:26:24 +0000 (17:26 -0700)
committerantirez <antirez@gmail.com>
Sun, 6 May 2012 08:06:21 +0000 (10:06 +0200)
Because of the introduction of new integer encoding types for ziplists
in the 2.6 tree, the same integer value may have a different encoding in
different versions of the ziplist implementation. This means that the
encoding can NOT be used as a fast path in comparing integers.

src/ziplist.c

index e3741f81eb16fd063298e50ce0dfbb0b5123125d..31e61633e5b1ad494468b021658ed75f455cf2cc 100644 (file)
@@ -773,12 +773,11 @@ unsigned int ziplistCompare(unsigned char *p, unsigned char *sstr, unsigned int
             return 0;
         }
     } else {
-        /* Try to compare encoded values */
+        /* Try to compare encoded values. Don't compare encoding because
+         * different implementations may encoded integers differently. */
         if (zipTryEncoding(sstr,slen,&sval,&sencoding)) {
-            if (entry.encoding == sencoding) {
-                zval = zipLoadInteger(p+entry.headersize,entry.encoding);
-                return zval == sval;
-            }
+          zval = zipLoadInteger(p+entry.headersize,entry.encoding);
+          return zval == sval;
         }
     }
     return 0;