1
0
mirror of https://github.com/fluencelabs/redis synced 2025-04-02 15:51:05 +00:00

RDB: load string objects directly as EMBSTR objects when possible.

This commit is contained in:
antirez 2014-07-16 11:36:22 +02:00
parent 9e7e0cd613
commit c7822bf382

@ -333,7 +333,7 @@ int rdbSaveStringObject(rio *rdb, robj *obj) {
robj *rdbGenericLoadStringObject(rio *rdb, int encode) { robj *rdbGenericLoadStringObject(rio *rdb, int encode) {
int isencoded; int isencoded;
uint32_t len; uint32_t len;
sds val; robj *o;
len = rdbLoadLen(rdb,&isencoded); len = rdbLoadLen(rdb,&isencoded);
if (isencoded) { if (isencoded) {
@ -350,12 +350,13 @@ robj *rdbGenericLoadStringObject(rio *rdb, int encode) {
} }
if (len == REDIS_RDB_LENERR) return NULL; if (len == REDIS_RDB_LENERR) return NULL;
val = sdsnewlen(NULL,len); o = encode ? createStringObject(NULL,len) :
if (len && rioRead(rdb,val,len) == 0) { createRawStringObject(NULL,len);
sdsfree(val); if (len && rioRead(rdb,o->ptr,len) == 0) {
decrRefCount(o);
return NULL; return NULL;
} }
return createObject(REDIS_STRING,val); return o;
} }
robj *rdbLoadStringObject(rio *rdb) { robj *rdbLoadStringObject(rio *rdb) {