diff --git a/src/core/compact_object.h b/src/core/compact_object.h index 7e878a6c9..4893b0c34 100644 --- a/src/core/compact_object.h +++ b/src/core/compact_object.h @@ -34,8 +34,9 @@ class RobjWrapper { public: using MemoryResource = PMR_NS::memory_resource; - RobjWrapper() { + RobjWrapper() : sz_(0), type_(0), encoding_(0) { } + size_t MallocUsed() const; uint64_t HashCode() const; @@ -78,7 +79,7 @@ class RobjWrapper { size_t InnerObjMallocUsed() const; void MakeInnerRoom(size_t current_cap, size_t desired, MemoryResource* mr); - void Set(void* p, uint32_t s) { + void Set(void* p, size_t s) { inner_obj_ = p; sz_ = s; } @@ -86,14 +87,14 @@ class RobjWrapper { void* inner_obj_ = nullptr; // semantics depend on the type. For OBJ_STRING it's string length. - uint32_t sz_ = 0; - - uint32_t type_ : 4; - uint32_t encoding_ : 4; - uint32_t : 24; + uint64_t sz_ : 56; + uint64_t type_ : 4; + uint64_t encoding_ : 4; } __attribute__((packed)); +static_assert(sizeof(RobjWrapper) == 16); + struct TieredColdRecord; } // namespace detail diff --git a/src/redis/quicklist.c b/src/redis/quicklist.c index 28fd439eb..495ab802a 100644 --- a/src/redis/quicklist.c +++ b/src/redis/quicklist.c @@ -1375,43 +1375,6 @@ void quicklistSetDirection(quicklistIter *iter, int direction) { iter->direction = direction; } -/* Duplicate the quicklist. - * On success a copy of the original quicklist is returned. - * - * The original quicklist both on success or error is never modified. - * - * Returns newly allocated quicklist. */ -quicklist *quicklistDup(quicklist *orig) { - quicklist *copy; - - copy = quicklistNew(orig->fill, orig->compress); - - for (quicklistNode *current = orig->head; current; current = current->next) { - quicklistNode *node = quicklistCreateNode(); - - if (current->encoding == QUICKLIST_NODE_ENCODING_LZF) { - quicklistLZF *lzf = (quicklistLZF *)current->entry; - size_t lzf_sz = sizeof(*lzf) + lzf->sz; - node->entry = zmalloc(lzf_sz); - memcpy(node->entry, current->entry, lzf_sz); - } else if (current->encoding == QUICKLIST_NODE_ENCODING_RAW) { - node->entry = zmalloc(current->sz); - memcpy(node->entry, current->entry, current->sz); - } - - node->count = current->count; - copy->count += node->count; - node->sz = current->sz; - node->encoding = current->encoding; - node->container = current->container; - - _quicklistInsertNodeAfter(copy, copy->tail, node); - } - - /* copy->count must equal orig->count here */ - return copy; -} - /* Populate 'entry' with the element at the specified zero-based index * where 0 is the head, 1 is the element next to head * and so on. Negative integers are used in order to count diff --git a/src/redis/quicklist.h b/src/redis/quicklist.h index e117226ac..0544c020e 100644 --- a/src/redis/quicklist.h +++ b/src/redis/quicklist.h @@ -176,7 +176,6 @@ quicklistIter *quicklistGetIteratorEntryAtIdx(quicklist *quicklist, const long l int quicklistNext(quicklistIter *iter, quicklistEntry *entry); void quicklistSetDirection(quicklistIter *iter, int direction); void quicklistReleaseIterator(quicklistIter *iter); -quicklist *quicklistDup(quicklist *orig); void quicklistRotate(quicklist *quicklist); int quicklistPopCustom(quicklist *quicklist, int where,