]> git.saurik.com Git - redis.git/commitdiff
change ziplistRepr to use the entry struct
authorPieter Noordhuis <pcnoordhuis@gmail.com>
Sat, 29 May 2010 14:25:05 +0000 (16:25 +0200)
committerPieter Noordhuis <pcnoordhuis@gmail.com>
Sat, 29 May 2010 19:10:17 +0000 (21:10 +0200)
ziplist.c

index 08253f37e63d7f6cf5d0e2dcbcbf426aedf59e8c..a04124215f6fa33ada41462a99ecb742a6e6ee08 100644 (file)
--- a/ziplist.c
+++ b/ziplist.c
@@ -496,24 +496,22 @@ unsigned int ziplistSize(unsigned char *zl) {
 }
 
 void ziplistRepr(unsigned char *zl) {
-    unsigned char *p, encoding;
-    unsigned int prevrawlensize, prevrawlen, lensize, len;
+    unsigned char *p;
+    zlentry entry;
 
     printf("{total bytes %d} {length %u}\n",ZIPLIST_BYTES(zl), ZIPLIST_LENGTH(zl));
     p = ziplistHead(zl);
     while(*p != ZIP_END) {
-        prevrawlen = zipDecodeLength(p,&prevrawlensize);
-        len = zipDecodeLength(p+prevrawlensize,&lensize);
-        printf("{offset %ld, header %u, payload %u} ",p-zl,prevrawlensize+lensize,len);
-        encoding = ZIP_ENCODING(p+prevrawlensize);
-        p += prevrawlensize+lensize;
-        if (encoding == ZIP_ENC_RAW) {
-            fwrite(p,len,1,stdout);
+        entry = zipEntry(p);
+        printf("{offset %ld, header %u, payload %u} ",p-zl,entry.headersize,entry.len);
+        p += entry.headersize;
+        if (entry.encoding == ZIP_ENC_RAW) {
+            fwrite(p,entry.len,1,stdout);
         } else {
-            printf("%lld", zipLoadInteger(p,encoding));
+            printf("%lld", zipLoadInteger(p,entry.encoding));
         }
         printf("\n");
-        p += len;
+        p += entry.len;
     }
     printf("{end}\n\n");
 }