MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / _quicklistNodeAllowMerge

Function _quicklistNodeAllowMerge

src/quicklist.c:462–481  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

460}
461
462REDIS_STATIC int _quicklistNodeAllowMerge(const quicklistNode *a,
463 const quicklistNode *b,
464 const int fill) {
465 if (!a || !b)
466 return 0;
467
468 /* approximate merged ziplist size (- 11 to remove one ziplist
469 * header/trailer) */
470 unsigned int merge_sz = a->sz + b->sz - 11;
471 if (likely(_quicklistNodeSizeMeetsOptimizationRequirement(merge_sz, fill)))
472 return 1;
473 /* when we return 1 above we know that the limit is a size limit (which is
474 * safe, see comments next to optimization_level and SIZE_SAFETY_LIMIT) */
475 else if (!sizeMeetsSafetyLimit(merge_sz))
476 return 0;
477 else if ((int)(a->count + b->count) <= fill)
478 return 1;
479 else
480 return 0;
481}
482
483#define quicklistNodeUpdateSz(node) \
484 do { \

Callers 1

_quicklistMergeNodesFunction · 0.85

Tested by

no test coverage detected