astutils.h: use pre-sized SmallVector in visitAstNodes() (#3919)
This commit is contained in:
parent
eeb6db05f1
commit
083efe6361
|
@ -56,11 +56,9 @@ void visitAstNodes(T *ast, const TFunc &visitor)
|
||||||
if (!ast)
|
if (!ast)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
std::vector<T *> tokensContainer;
|
|
||||||
// the size of 8 was determined in tests to be sufficient to avoid excess allocations. also add 1 as a buffer.
|
// the size of 8 was determined in tests to be sufficient to avoid excess allocations. also add 1 as a buffer.
|
||||||
// we might need to increase that value in the future.
|
// we might need to increase that value in the future.
|
||||||
tokensContainer.reserve(8 + 1);
|
std::stack<T *, SmallVector<T *, 8 + 1>> tokens;
|
||||||
std::stack<T *, std::vector<T *>> tokens(std::move(tokensContainer));
|
|
||||||
T *tok = ast;
|
T *tok = ast;
|
||||||
do {
|
do {
|
||||||
ChildrenToVisit c = visitor(tok);
|
ChildrenToVisit c = visitor(tok);
|
||||||
|
|
Loading…
Reference in New Issue