From 127c15e2b2429c602797e56d8f7e1fdec312c68f Mon Sep 17 00:00:00 2001 From: Matt Stancliff Date: Wed, 10 Dec 2014 15:46:24 -0500 Subject: [PATCH] Convert RDB ziplist loading to sdsnative() This saves us an unnecessary zmalloc, memcpy, and two frees. --- src/rdb.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/rdb.c b/src/rdb.c index 70989897..14d6dea8 100644 --- a/src/rdb.c +++ b/src/rdb.c @@ -981,13 +981,9 @@ robj *rdbLoadObject(int rdbtype, rio *rdb) { rdbtype == REDIS_RDB_TYPE_ZSET_ZIPLIST || rdbtype == REDIS_RDB_TYPE_HASH_ZIPLIST) { - robj *aux = rdbLoadStringObject(rdb); - - if (aux == NULL) return NULL; - 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); + o = rdbLoadStringObject(rdb); + if (o == NULL) return NULL; + o->ptr = sdsnative(o->ptr); /* Fix the object encoding, and make sure to convert the encoded * data type into the base type if accordingly to the current