TokenList::validateAst: optimised ~25%

This commit is contained in:
Daniel Marjamäki 2018-05-09 12:36:58 +02:00
parent ecccce0608
commit ab6167e3e6
1 changed files with 5 additions and 2 deletions

View File

@ -1183,7 +1183,7 @@ void TokenList::validateAst() const
throw InternalError(tok, "Syntax Error: AST broken, ternary operator lacks ':'.", InternalError::AST); throw InternalError(tok, "Syntax Error: AST broken, ternary operator lacks ':'.", InternalError::AST);
// Check for endless recursion // Check for endless recursion
const Token* parent=tok->astParent(); const Token* parent = tok->astParent();
if (parent) { if (parent) {
std::set < const Token* > astTokens; // list of anchestors std::set < const Token* > astTokens; // list of anchestors
astTokens.insert(tok); astTokens.insert(tok);
@ -1195,8 +1195,11 @@ void TokenList::validateAst() const
astTokens.insert(parent); astTokens.insert(parent);
} while ((parent = parent->astParent()) != nullptr); } while ((parent = parent->astParent()) != nullptr);
safeAstTokens.insert(astTokens.begin(), astTokens.end()); safeAstTokens.insert(astTokens.begin(), astTokens.end());
} else } else if (tok->str() == ";") {
safeAstTokens.clear();
} else {
safeAstTokens.insert(tok); safeAstTokens.insert(tok);
}
} }
} }