make memory usage consistent of robj with OBJ_ENCODING_INT

This commit is contained in:
chendianqiang 2019-07-22 17:45:30 +08:00
parent 49816941a4
commit 004c26ec28

View File

@ -455,10 +455,15 @@ robj *tryObjectEncoding(robj *o) {
incrRefCount(shared.integers[value]);
return shared.integers[value];
} else {
if (o->encoding == OBJ_ENCODING_RAW) sdsfree(o->ptr);
o->encoding = OBJ_ENCODING_INT;
o->ptr = (void*) value;
return o;
if (o->encoding == OBJ_ENCODING_RAW) {
sdsfree(o->ptr);
o->encoding = OBJ_ENCODING_INT;
o->ptr = (void*) value;
return o;
} else {
decrRefCount(o);
return createStringObjectFromLongLongForValue(value);
}
}
}