Skip to content

Commit

Permalink
Trivial cleanup of iterateAndNext
Browse files Browse the repository at this point in the history
  • Loading branch information
gezalore committed Oct 21, 2023
1 parent 7d06649 commit 9e79095
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/V3Ast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -958,15 +958,12 @@ void AstNode::iterateAndNext(VNVisitor& v) {
// This is a very hot function
// IMPORTANT: If you replace a node that's the target of this iterator,
// then the NEW node will be iterated on next, it isn't skipped!
// Future versions of this function may require the node to have a back to be iterated;
// there's no lower level reason yet though the back must exist.
AstNode* nodep = this;
#ifdef VL_DEBUG // Otherwise too hot of a function for debug
UASSERT_OBJ(!(nodep && !nodep->m_backp), nodep, "iterateAndNext node has no back");
UASSERT_OBJ(nodep->m_backp, nodep, "iterateAndNext node has no back");
#endif
// cppcheck-suppress knownConditionTrueFalse
if (nodep) ASTNODE_PREFETCH(nodep->m_nextp);
while (nodep) { // effectively: if (!this) return; // Callers rely on this
ASTNODE_PREFETCH_NON_NULL(nodep->m_nextp);
do {
if (nodep->m_nextp) ASTNODE_PREFETCH(nodep->m_nextp->m_nextp);
AstNode* niterp = nodep; // Pointer may get stomped via m_iterpp if the node is edited
// Desirable check, but many places where multiple iterations are OK
Expand All @@ -986,7 +983,7 @@ void AstNode::iterateAndNext(VNVisitor& v) {
} else { // Unchanged node (though maybe updated m_next), just continue loop
nodep = niterp->m_nextp;
}
}
} while (nodep);
}

void AstNode::iterateListBackwardsConst(VNVisitorConst& v) {
Expand Down

0 comments on commit 9e79095

Please sign in to comment.