Skip to content

Commit 127c15e

Browse files
committed
Convert RDB ziplist loading to sdsnative()
This saves us an unnecessary zmalloc, memcpy, and two frees.
1 parent e161977 commit 127c15e

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/rdb.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -981,13 +981,9 @@ robj *rdbLoadObject(int rdbtype, rio *rdb) {
981981
rdbtype == REDIS_RDB_TYPE_ZSET_ZIPLIST ||
982982
rdbtype == REDIS_RDB_TYPE_HASH_ZIPLIST)
983983
{
984-
robj *aux = rdbLoadStringObject(rdb);
985-
986-
if (aux == NULL) return NULL;
987-
o = createObject(REDIS_STRING,NULL); /* string is just placeholder */
988-
o->ptr = zmalloc(sdslen(aux->ptr));
989-
memcpy(o->ptr,aux->ptr,sdslen(aux->ptr));
990-
decrRefCount(aux);
984+
o = rdbLoadStringObject(rdb);
985+
if (o == NULL) return NULL;
986+
o->ptr = sdsnative(o->ptr);
991987

992988
/* Fix the object encoding, and make sure to convert the encoded
993989
* data type into the base type if accordingly to the current

0 commit comments

Comments
 (0)