Skip to content

Commit fe25c15

Browse files
committed
astutils.h: use pre-sized SmallVector in visitAstNodes()
1 parent 56e2af5 commit fe25c15

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

lib/astutils.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "config.h"
3434
#include "errortypes.h"
3535
#include "library.h"
36+
#include "smallvector.h"
3637
#include "symboldatabase.h"
3738

3839
class Settings;
@@ -55,11 +56,9 @@ void visitAstNodes(T *ast, const TFunc &visitor)
5556
if (!ast)
5657
return;
5758

58-
std::vector<T *> tokensContainer;
5959
// the size of 8 was determined in tests to be sufficient to avoid excess allocations. also add 1 as a buffer.
6060
// we might need to increase that value in the future.
61-
tokensContainer.reserve(8 + 1);
62-
std::stack<T *, std::vector<T *>> tokens(std::move(tokensContainer));
61+
std::stack<T *, SmallVector<T *, 8 + 1>> tokens;
6362
T *tok = ast;
6463
do {
6564
ChildrenToVisit c = visitor(tok);

0 commit comments

Comments
 (0)