mirror of
https://github.com/fluencelabs/redis
synced 2025-03-19 17:10:50 +00:00
Convert RDB ziplist loading to sdsnative()
This saves us an unnecessary zmalloc, memcpy, and two frees.
This commit is contained in:
parent
e1619772db
commit
127c15e2b2
10
src/rdb.c
10
src/rdb.c
@ -981,13 +981,9 @@ robj *rdbLoadObject(int rdbtype, rio *rdb) {
|
|||||||
rdbtype == REDIS_RDB_TYPE_ZSET_ZIPLIST ||
|
rdbtype == REDIS_RDB_TYPE_ZSET_ZIPLIST ||
|
||||||
rdbtype == REDIS_RDB_TYPE_HASH_ZIPLIST)
|
rdbtype == REDIS_RDB_TYPE_HASH_ZIPLIST)
|
||||||
{
|
{
|
||||||
robj *aux = rdbLoadStringObject(rdb);
|
o = rdbLoadStringObject(rdb);
|
||||||
|
if (o == NULL) return NULL;
|
||||||
if (aux == NULL) return NULL;
|
o->ptr = sdsnative(o->ptr);
|
||||||
o = createObject(REDIS_STRING,NULL); /* string is just placeholder */
|
|
||||||
o->ptr = zmalloc(sdslen(aux->ptr));
|
|
||||||
memcpy(o->ptr,aux->ptr,sdslen(aux->ptr));
|
|
||||||
decrRefCount(aux);
|
|
||||||
|
|
||||||
/* Fix the object encoding, and make sure to convert the encoded
|
/* Fix the object encoding, and make sure to convert the encoded
|
||||||
* data type into the base type if accordingly to the current
|
* data type into the base type if accordingly to the current
|
||||||
|
Loading…
x
Reference in New Issue
Block a user