PFCOUNT: always unshare/decode the object.
This will be a non-op most of the times since the object will be unshared / decoded, however it is more technically correct to start this way since the object may be decoded even in the read-only code path.
This commit is contained in:
parent
1c12bcbcfb
commit
d5be696db8
@ -520,6 +520,7 @@ void pfcountCommand(redisClient *c) {
|
|||||||
addReply(c,shared.czero);
|
addReply(c,shared.czero);
|
||||||
} else {
|
} else {
|
||||||
if (isHLLObjectOrReply(c,o) != REDIS_OK) return;
|
if (isHLLObjectOrReply(c,o) != REDIS_OK) return;
|
||||||
|
o = dbUnshareStringValue(c->db,c->argv[1],o);
|
||||||
|
|
||||||
/* Check if the cached cardinality is valid. */
|
/* Check if the cached cardinality is valid. */
|
||||||
registers = o->ptr;
|
registers = o->ptr;
|
||||||
@ -535,9 +536,6 @@ void pfcountCommand(redisClient *c) {
|
|||||||
card |= (uint64_t)registers[REDIS_HLL_SIZE-9] << 56;
|
card |= (uint64_t)registers[REDIS_HLL_SIZE-9] << 56;
|
||||||
} else {
|
} else {
|
||||||
/* Recompute it and update the cached value. */
|
/* Recompute it and update the cached value. */
|
||||||
o = dbUnshareStringValue(c->db,c->argv[1],o);
|
|
||||||
registers = o->ptr;
|
|
||||||
|
|
||||||
card = hllCount(registers);
|
card = hllCount(registers);
|
||||||
registers[REDIS_HLL_SIZE-16] = card & 0xff;
|
registers[REDIS_HLL_SIZE-16] = card & 0xff;
|
||||||
registers[REDIS_HLL_SIZE-15] = (card >> 8) & 0xff;
|
registers[REDIS_HLL_SIZE-15] = (card >> 8) & 0xff;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user