Add Entry::pointClear

This commit is contained in:
2024-05-29 16:13:45 -07:00
parent f1f4d66678
commit dab6929e88

View File

@@ -91,6 +91,7 @@ struct Entry {
// True if the entry is a point mutation. If false, this entry's key should be
// read through to the underlying data structure.
bool pointMutation() const { return pointVersion >= 0; }
bool pointClear() const { return pointVersion >= 0 && valLen < 0; }
// True if mutations in (pred, this) are cleared. If false, (pred, this)
// should be read through to the underlying data structure.
@@ -1065,8 +1066,7 @@ void materializeMutations(VersionedMap::Iterator::Impl *impl, const Entry *prev,
impl->mutations[impl->mutationCount++] = {
prev->getKey(),
entry.getKey(),
prev->pointMutation() && prev->valLen < 0 &&
prev->pointVersion == entry.rangeVersion
prev->pointClear() && prev->pointVersion == entry.rangeVersion
? prev->keyLen
: prev->keyLen + 1,
entry.keyLen,
@@ -1074,7 +1074,7 @@ void materializeMutations(VersionedMap::Iterator::Impl *impl, const Entry *prev,
entry.rangeVersion};
}
if (entry.pointMutation()) {
if (entry.valLen < 0) {
if (entry.valLen < 0 /* pointClear */) {
if (next == nullptr ||
!(next->clearTo() && next->rangeVersion == entry.pointVersion)) {
impl->mutations[impl->mutationCount++] = {