Allow ReusableNode to advance off the end of the tree
Co-Authored-By: Rick Winfrey <rewinfrey@github.com>
This commit is contained in:
parent
5fa6d39578
commit
8d805feab1
1 changed files with 7 additions and 2 deletions
|
|
@ -25,11 +25,15 @@ static inline void reusable_node_reset(ReusableNode *self, Tree *tree) {
|
|||
}
|
||||
|
||||
static inline Tree *reusable_node_tree(ReusableNode *self) {
|
||||
return array_back(&self->stack)->tree;
|
||||
return self->stack.size > 0
|
||||
? self->stack.contents[self->stack.size - 1].tree
|
||||
: NULL;
|
||||
}
|
||||
|
||||
static inline uint32_t reusable_node_byte_offset(ReusableNode *self) {
|
||||
return array_back(&self->stack)->byte_offset;
|
||||
return self->stack.size > 0
|
||||
? self->stack.contents[self->stack.size - 1].byte_offset
|
||||
: UINT32_MAX;
|
||||
}
|
||||
|
||||
static inline void reusable_node_delete(ReusableNode *self) {
|
||||
|
|
@ -52,6 +56,7 @@ static inline void reusable_node_advance(ReusableNode *self) {
|
|||
do {
|
||||
StackEntry popped_entry = array_pop(&self->stack);
|
||||
next_index = popped_entry.child_index + 1;
|
||||
if (self->stack.size == 0) return;
|
||||
tree = array_back(&self->stack)->tree;
|
||||
} while (tree->children.size <= next_index);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue