diff --git a/ConflictSet.cpp b/ConflictSet.cpp index 76adb35..77880d2 100644 --- a/ConflictSet.cpp +++ b/ConflictSet.cpp @@ -292,9 +292,10 @@ static_assert(kNode3Surplus >= kMinNodeSurplus); static_assert(kBytesPerKey - sizeof(Node0) >= kMinNodeSurplus); // setOldestVersion will additionally try to maintain this property: -// `max(children, 1) * length >= capacity` +// `(children + entryPresent) * length >= capacity` // -// Which should give us the budget to pay for the key bytes +// Which should give us the budget to pay for the key bytes. (children + +// entryPresent) is a lower bound on how many keys these bytes are a prefix of template struct BoundedFreeListAllocator { @@ -910,7 +911,7 @@ void makeCapacityAtLeast(Node *&self, int capacity, NodeAllocators *allocators, void maybeDecreaseCapacity(Node *&self, NodeAllocators *allocators, ConflictSet::Impl *impl) { const int maxCapacity = - std::max(self->numChildren, 1) * self->partialKeyLen; + (self->numChildren + int(self->entryPresent)) * self->partialKeyLen; if (self->partialKeyCapacity <= maxCapacity) { return; }