File tree Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Original file line number Diff line number Diff line change 25
25
#include < cstdint>
26
26
#include < functional>
27
27
#include < list>
28
- #include < stack>
29
28
#include < string>
30
29
#include < type_traits>
31
30
#include < utility>
@@ -64,29 +63,29 @@ void visitAstNodes(T *ast, const TFunc &visitor)
64
63
65
64
// the size of 8 was determined in tests to be sufficient to avoid excess allocations. also add 1 as a buffer.
66
65
// we might need to increase that value in the future.
67
- std::stack<T *, SmallVector<T *, 8 + 1 > > tokens;
66
+ SmallVector<T *, 8 + 1 > tokens;
68
67
T *tok = ast;
69
68
do {
70
69
const ChildrenToVisit c = visitor (tok);
71
-
72
70
if (c == ChildrenToVisit::done)
73
71
break ;
72
+
74
73
if (c == ChildrenToVisit::op2 || c == ChildrenToVisit::op1_and_op2) {
75
74
T *t2 = tok->astOperand2 ();
76
75
if (t2)
77
- tokens.push (t2);
76
+ tokens.push_back (t2);
78
77
}
79
78
if (c == ChildrenToVisit::op1 || c == ChildrenToVisit::op1_and_op2) {
80
79
T *t1 = tok->astOperand1 ();
81
80
if (t1)
82
- tokens.push (t1);
81
+ tokens.push_back (t1);
83
82
}
84
83
85
84
if (tokens.empty ())
86
85
break ;
87
86
88
- tok = tokens.top ();
89
- tokens.pop ();
87
+ tok = tokens.back ();
88
+ tokens.pop_back ();
90
89
} while (true );
91
90
}
92
91
You can’t perform that action at this time.
0 commit comments