mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-23 00:28:26 -05:00
Merge pull request #5131 from soloestoy/optimize-xdel
Streams: free lp if all elements are deleted
This commit is contained in:
commit
a317f55d25
@ -705,10 +705,15 @@ void streamIteratorRemoveEntry(streamIterator *si, streamID *current) {
|
||||
/* Change the valid/deleted entries count in the master entry. */
|
||||
unsigned char *p = lpFirst(lp);
|
||||
aux = lpGetInteger(p);
|
||||
lp = lpReplaceInteger(lp,&p,aux-1);
|
||||
p = lpNext(lp,p); /* Seek deleted field. */
|
||||
aux = lpGetInteger(p);
|
||||
lp = lpReplaceInteger(lp,&p,aux+1);
|
||||
if (aux == 1) {
|
||||
lpFree(lp);
|
||||
raxRemove(si->stream->rax,si->ri.key,si->ri.key_len,NULL);
|
||||
} else {
|
||||
lp = lpReplaceInteger(lp,&p,aux-1);
|
||||
p = lpNext(lp,p); /* Seek deleted field. */
|
||||
aux = lpGetInteger(p);
|
||||
lp = lpReplaceInteger(lp,&p,aux+1);
|
||||
}
|
||||
|
||||
/* Update the number of entries counter. */
|
||||
si->stream->length--;
|
||||
|
Loading…
Reference in New Issue
Block a user