mirror of
https://github.com/fluencelabs/redis
synced 2025-03-19 09:00:51 +00:00
Merge pull request #2050 from mattsta/bitops-no-overalloc
Bitops: Stop overallocating storage space on set
This commit is contained in:
commit
9454f7b3db
@ -229,19 +229,17 @@ void setbitCommand(redisClient *c) {
|
||||
return;
|
||||
}
|
||||
|
||||
byte = bitoffset >> 3;
|
||||
o = lookupKeyWrite(c->db,c->argv[1]);
|
||||
if (o == NULL) {
|
||||
o = createObject(REDIS_STRING,sdsempty());
|
||||
o = createObject(REDIS_STRING,sdsnewlen(NULL, byte+1));
|
||||
dbAdd(c->db,c->argv[1],o);
|
||||
} else {
|
||||
if (checkType(c,o,REDIS_STRING)) return;
|
||||
o = dbUnshareStringValue(c->db,c->argv[1],o);
|
||||
o->ptr = sdsgrowzero(o->ptr,byte+1);
|
||||
}
|
||||
|
||||
/* Grow sds value to the right length if necessary */
|
||||
byte = bitoffset >> 3;
|
||||
o->ptr = sdsgrowzero(o->ptr,byte+1);
|
||||
|
||||
/* Get current values */
|
||||
byteval = ((uint8_t*)o->ptr)[byte];
|
||||
bit = 7 - (bitoffset & 0x7);
|
||||
|
@ -206,7 +206,7 @@ void setrangeCommand(redisClient *c) {
|
||||
if (checkStringLength(c,offset+sdslen(value)) != REDIS_OK)
|
||||
return;
|
||||
|
||||
o = createObject(REDIS_STRING,sdsempty());
|
||||
o = createObject(REDIS_STRING,sdsnewlen(NULL, offset+sdslen(value)));
|
||||
dbAdd(c->db,c->argv[1],o);
|
||||
} else {
|
||||
size_t olen;
|
||||
|
Loading…
x
Reference in New Issue
Block a user