diff options
Diffstat (limited to 'src/t_string.c')
-rw-r--r-- | src/t_string.c | 16 |
1 files changed, 2 insertions, 14 deletions
diff --git a/src/t_string.c b/src/t_string.c index 3645ae7c5..41e4b3b71 100644 --- a/src/t_string.c +++ b/src/t_string.c @@ -215,12 +215,7 @@ void setrangeCommand(redisClient *c) { return; /* Create a copy when the object is shared or encoded. */ - if (o->refcount != 1 || o->encoding != REDIS_ENCODING_RAW) { - robj *decoded = getDecodedObject(o); - o = createRawStringObject(decoded->ptr, sdslen(decoded->ptr)); - decrRefCount(decoded); - dbOverwrite(c->db,c->argv[1],o); - } + o = dbUnshareStringValue(c->db,c->argv[1],o); } if (sdslen(value) > 0) { @@ -433,15 +428,8 @@ void appendCommand(redisClient *c) { if (checkStringLength(c,totlen) != REDIS_OK) return; - /* If the object is shared or encoded, we have to make a copy */ - if (o->refcount != 1 || o->encoding != REDIS_ENCODING_RAW) { - robj *decoded = getDecodedObject(o); - o = createRawStringObject(decoded->ptr, sdslen(decoded->ptr)); - decrRefCount(decoded); - dbOverwrite(c->db,c->argv[1],o); - } - /* Append the value */ + o = dbUnshareStringValue(c->db,c->argv[1],o); o->ptr = sdscatlen(o->ptr,append->ptr,sdslen(append->ptr)); totlen = sdslen(o->ptr); } |