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:
antirez
2014-03-30 18:32:17 +02:00
parent aaf6db459b
commit 543ede03f2
6 changed files with 44 additions and 31 deletions

@ -660,7 +660,7 @@ unsigned long long estimateObjectIdleTime(robj *o) {
}
}
/* This is a helper function for the DEBUG command. We need to lookup keys
/* This is a helper function for the OBJECT command. We need to lookup keys
* without any modification of LRU or other parameters. */
robj *objectCommandLookup(redisClient *c, robj *key) {
dictEntry *de;