mirror of
https://github.com/fluencelabs/redis
synced 2025-06-16 18:51:20 +00:00
String value unsharing refactored into proper function.
All the Redis functions that need to modify the string value of a key in a destructive way (APPEND, SETBIT, SETRANGE, ...) require to make the object unshared (if refcount > 1) and encoded in raw format (if encoding is not already REDIS_ENCODING_RAW). This was cut & pasted many times in multiple places of the code. This commit puts the small logic needed into a function called dbUnshareStringValue().
This commit is contained in:
@ -424,14 +424,7 @@ void hllAddCommand(redisClient *c) {
|
||||
REDIS_HLL_SIZE);
|
||||
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);
|
||||
}
|
||||
o = dbUnshareStringValue(c->db,c->argv[1],o);
|
||||
}
|
||||
/* Perform the low level ADD operation for every element. */
|
||||
registers = o->ptr;
|
||||
|
Reference in New Issue
Block a user