fix(DenseSet): Rename Size() to UpperBoundSize() and add SizeSlow() (#2130)

Then use the right version (hopefully) in the right places.

Specifically, this fixes a serialization bug, where we could send
malformed responses when using `UpperBoundSize()` to write array length.
This commit is contained in:
Shahar Mike 2023-11-06 08:52:08 +02:00 committed by GitHub
parent f809fb04bc
commit 7e23c14c35
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 48 additions and 41 deletions

View file

@ -671,4 +671,17 @@ bool DenseSet::ExpireIfNeededInternal(DensePtr* prev, DensePtr* node) const {
return deleted;
}
void DenseSet::CollectExpired() {
// Simply iterating over all items will remove expired
auto it = IteratorBase(this, false);
while (it.curr_entry_ != nullptr) {
it.Advance();
}
}
size_t DenseSet::SizeSlow() {
CollectExpired();
return size_;
}
} // namespace dfly