From 22632fc9f2090d8c1f8f532f086fb3aa911cff65 Mon Sep 17 00:00:00 2001 From: Andrew Noyes Date: Fri, 22 Nov 2024 15:29:24 -0800 Subject: [PATCH] Add IteratorBase::type --- ConflictSet.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/ConflictSet.cpp b/ConflictSet.cpp index 63829eb..fbae0e0 100644 --- a/ConflictSet.cpp +++ b/ConflictSet.cpp @@ -1887,10 +1887,12 @@ void downsize(Node *self, WriteContext *writeContext) { template struct Iterator; -// Higher-level handle to a position in the tree +// Higher-level handle to a position in the tree. Can represent the position of +// an entry associated with a node or a leaf. struct IteratorBase { - explicit IteratorBase(Node *node) : node(node) {} + explicit IteratorBase(Node *node) + : node(node), type(node ? node->getType() : Type_Node0) {} bool entryPresent() { return node->entryPresent; } Entry getEntry() { @@ -1938,6 +1940,7 @@ struct IteratorBase { protected: Node *node; + Type type; // index into children array of particular leaf type int index; }; @@ -1964,7 +1967,7 @@ template struct Iterator : IteratorBase { }; TrivialSpan IteratorBase::partialKey() { - switch (node->getType()) { + switch (type) { case Type_Node0: return as().partialKey(); case Type_Node3: @@ -1981,7 +1984,7 @@ TrivialSpan IteratorBase::partialKey() { } IteratorBase IteratorBase::getFirstChild() { - switch (node->getType()) { + switch (type) { case Type_Node0: return as().getFirstChild(); case Type_Node3: @@ -1999,7 +2002,7 @@ IteratorBase IteratorBase::getFirstChild() { IteratorBase::ChildAndMaxVersion IteratorBase::getChildAndMaxVersion(int index) { - switch (node->getType()) { + switch (type) { case Type_Node0: return as().getChildAndMaxVersion(index); case Type_Node3: @@ -2016,7 +2019,7 @@ IteratorBase::getChildAndMaxVersion(int index) { } IteratorBase IteratorBase::getChildGeq(int index) { - switch (node->getType()) { + switch (type) { case Type_Node0: return as().getChildGeq(index); case Type_Node3: