Skip to content

Commit

Permalink
hllSparseAdd(): more correct dense conversion conditional.
Browse files Browse the repository at this point in the history
We want to promote if the total string size exceeds the resulting size
after the upgrade.
  • Loading branch information
antirez committed Apr 14, 2014
1 parent b7571b7 commit 3b20003
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/hyperloglog.c
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ int hllSparseAdd(robj *o, unsigned char *ele, size_t elesize) {
int oldlen = is_xzero ? 2 : 1;
int deltalen = seqlen-oldlen;

if (deltalen > 0 && sdslen(o->ptr) > HLL_SPARSE_MAX) goto promote;
if (deltalen > 0 && sdslen(o->ptr)+deltalen > HLL_SPARSE_MAX) goto promote;
if (deltalen && next) memmove(next+deltalen,next,next-sparse);
sdsIncrLen(o->ptr,deltalen);
memcpy(p,seq,seqlen);
Expand Down

0 comments on commit 3b20003

Please sign in to comment.