fix the size of variable merge_sz in quicklist.c (#11285)

11 was the size of header/trailer in the old structure Ziplist,
but now the size of header/trailer in the new structure Listpack should be 7.
This commit is contained in:
FutabaRio 2022-10-19 20:11:28 +08:00 committed by GitHub
parent b57fd01064
commit 6debeb3779
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -502,9 +502,9 @@ REDIS_STATIC int _quicklistNodeAllowMerge(const quicklistNode *a,
if (unlikely(QL_NODE_IS_PLAIN(a) || QL_NODE_IS_PLAIN(b)))
return 0;
/* approximate merged listpack size (- 11 to remove one listpack
* header/trailer) */
unsigned int merge_sz = a->sz + b->sz - 11;
/* approximate merged listpack size (- 7 to remove one listpack
* header/trailer, see LP_HDR_SIZE and LP_EOF) */
unsigned int merge_sz = a->sz + b->sz - 7;
if (likely(_quicklistNodeSizeMeetsOptimizationRequirement(merge_sz, fill)))
return 1;
/* when we return 1 above we know that the limit is a size limit (which is