chore: get rid of object.c and robj* in cc code (#2610)

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
This commit is contained in:
Roman Gershman 2024-02-18 16:52:23 +02:00 committed by GitHub
parent 417ca952d6
commit fa75360227
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
45 changed files with 94 additions and 1962 deletions

View file

@ -10,7 +10,7 @@
extern "C" {
#include "redis/intset.h"
#include "redis/listpack.h"
#include "redis/object.h"
#include "redis/quicklist.h"
#include "redis/redis_aux.h"
#include "redis/stream.h"
#include "redis/util.h"
@ -199,9 +199,6 @@ static_assert(ascii_len(16) == 18);
static_assert(ascii_len(17) == 19);
struct TL {
robj tmp_robj{
.type = 0, .encoding = 0, .lru = 0, .refcount = OBJ_STATIC_REFCOUNT, .ptr = nullptr};
MemoryResource* local_mr = PMR_NS::get_default_resource();
size_t small_str_bytes;
base::PODArray<uint8_t> tmp_buf;
@ -671,42 +668,12 @@ unsigned CompactObj::Encoding() const {
}
}
robj* CompactObj::AsRObj() const {
CHECK_EQ(ROBJ_TAG, taglen_);
robj* res = &tl.tmp_robj;
unsigned enc = u_.r_obj.encoding();
res->type = u_.r_obj.type();
if (res->type == OBJ_SET || res->type == OBJ_HASH || res->type == OBJ_ZSET) {
LOG(DFATAL) << "Should not call AsRObj for type " << res->type;
}
res->encoding = enc;
res->lru = 0; // u_.r_obj.unneeded;
res->ptr = u_.r_obj.inner_obj();
return res;
}
void CompactObj::InitRobj(unsigned type, unsigned encoding, void* obj) {
DCHECK_NE(type, OBJ_STRING);
SetMeta(ROBJ_TAG, mask_);
u_.r_obj.Init(type, encoding, obj);
}
void CompactObj::SyncRObj() {
robj* obj = &tl.tmp_robj;
DCHECK_EQ(ROBJ_TAG, taglen_);
DCHECK_EQ(u_.r_obj.type(), obj->type);
DCHECK_NE(OBJ_SET, obj->type) << "sets should be handled without robj";
CHECK_NE(OBJ_ZSET, obj->type) << "zsets should be handled without robj";
unsigned enc = obj->encoding;
u_.r_obj.Init(obj->type, enc, obj->ptr);
}
void CompactObj::SetInt(int64_t val) {
if (INT_TAG != taglen_) {
SetMeta(INT_TAG, mask_ & ~kEncMask);