Skip to content

Commit 59995bb

Browse files
committed
Make counting of unmarked nodes in sharing map independent of tree depth
1 parent 4d3cb8c commit 59995bb

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

src/util/sharing_map.h

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -610,23 +610,15 @@ ::count_unmarked_nodes(
610610

611611
unsigned count = 0;
612612

613-
// depth, node pointer
614-
typedef std::pair<unsigned, const baset *> stack_itemt;
615-
616-
std::stack<stack_itemt> stack;
617-
stack.push({0, &map});
613+
std::stack<const innert *> stack;
614+
stack.push(&map);
618615

619616
do
620617
{
621-
const stack_itemt &si = stack.top();
622-
623-
const unsigned depth = si.first;
624-
const baset *bp = si.second;
625-
618+
const innert *ip = stack.top();
626619
stack.pop();
627620

628621
// internal node or container node
629-
const innert *ip = static_cast<const innert *>(bp);
630622
const unsigned use_count = ip->use_count();
631623
const void *raw_ptr = ip->is_internal()
632624
? (const void *)&ip->read_internal()
@@ -650,20 +642,22 @@ ::count_unmarked_nodes(
650642
count++;
651643
}
652644

653-
if(depth < steps) // internal
645+
if(ip->is_internal())
654646
{
647+
SM_ASSERT(!ip->empty());
648+
655649
const to_mapt &m = ip->get_to_map();
656650
SM_ASSERT(!m.empty());
657651

658652
for(const auto &item : m)
659653
{
660654
const innert *i = &item.second;
661-
stack.push({depth + 1, i});
655+
stack.push(i);
662656
}
663657
}
664-
else // container
658+
else
665659
{
666-
SM_ASSERT(depth == steps);
660+
SM_ASSERT(ip->is_defined_container());
667661

668662
const leaf_listt &ll = ip->get_container();
669663
SM_ASSERT(!ll.empty());

0 commit comments

Comments
 (0)