Avoid trying to trim string loaded from RDB file. (#12241)
This is a followup fix for #11817
This commit is contained in:
parent
0dfb0250e6
commit
c2f1815bcb
@ -629,7 +629,7 @@ void trimStringObjectIfNeeded(robj *o, int trim_small_values) {
|
||||
}
|
||||
|
||||
/* Try to encode a string object in order to save space */
|
||||
robj *tryObjectEncoding(robj *o) {
|
||||
robj *tryObjectEncodingEx(robj *o, int try_trim) {
|
||||
long value;
|
||||
sds s = o->ptr;
|
||||
size_t len;
|
||||
@ -694,12 +694,17 @@ robj *tryObjectEncoding(robj *o) {
|
||||
|
||||
/* We can't encode the object...
|
||||
* Do the last try, and at least optimize the SDS string inside */
|
||||
trimStringObjectIfNeeded(o, 0);
|
||||
if (try_trim)
|
||||
trimStringObjectIfNeeded(o, 0);
|
||||
|
||||
/* Return the original object. */
|
||||
return o;
|
||||
}
|
||||
|
||||
robj *tryObjectEncoding(robj *o) {
|
||||
return tryObjectEncodingEx(o, 1);
|
||||
}
|
||||
|
||||
/* Get a decoded version of an encoded object (returned as a new object).
|
||||
* If the object is already raw-encoded just increment the ref count. */
|
||||
robj *getDecodedObject(robj *o) {
|
||||
|
@ -1844,7 +1844,7 @@ robj *rdbLoadObject(int rdbtype, rio *rdb, sds key, int dbid, int *error) {
|
||||
if (rdbtype == RDB_TYPE_STRING) {
|
||||
/* Read string value */
|
||||
if ((o = rdbLoadEncodedStringObject(rdb)) == NULL) return NULL;
|
||||
o = tryObjectEncoding(o);
|
||||
o = tryObjectEncodingEx(o, 0);
|
||||
} else if (rdbtype == RDB_TYPE_LIST) {
|
||||
/* Read list value */
|
||||
if ((len = rdbLoadLen(rdb,NULL)) == RDB_LENERR) return NULL;
|
||||
|
@ -2738,6 +2738,7 @@ robj *dupStringObject(const robj *o);
|
||||
int isSdsRepresentableAsLongLong(sds s, long long *llval);
|
||||
int isObjectRepresentableAsLongLong(robj *o, long long *llongval);
|
||||
robj *tryObjectEncoding(robj *o);
|
||||
robj *tryObjectEncodingEx(robj *o, int try_trim);
|
||||
robj *getDecodedObject(robj *o);
|
||||
size_t stringObjectLen(robj *o);
|
||||
robj *createStringObjectFromLongLong(long long value);
|
||||
|
Loading…
x
Reference in New Issue
Block a user