tint/resolver: Use utils::Vector in a few places

Use the new vector type in some of the hot code paths of the resolver.

Bug: tint:1613
Change-Id: Ie56d8c96f73c9112f37934ad67e588513aafb982
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96282
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
Ben Clayton
2022-07-26 07:55:24 +00:00
committed by Dawn LUCI CQ
parent 4b3d53d141
commit 958a4642f1
38 changed files with 493 additions and 478 deletions

View File

@@ -26,6 +26,7 @@
#include "src/tint/ast/phony_expression.h"
#include "src/tint/ast/unary_op_expression.h"
#include "src/tint/utils/reverse.h"
#include "src/tint/utils/vector.h"
namespace tint::ast {
@@ -67,35 +68,34 @@ bool TraverseExpressions(const ast::Expression* root, diag::List& diags, CALLBAC
size_t depth;
};
std::vector<Pending> to_visit{{root, 0}};
utils::Vector<Pending, 64> to_visit{{root, 0}};
auto push_single = [&](const ast::Expression* expr, size_t depth) {
to_visit.push_back({expr, depth});
to_visit.Push({expr, depth});
};
auto push_pair = [&](const ast::Expression* left, const ast::Expression* right, size_t depth) {
if (ORDER == TraverseOrder::LeftToRight) {
to_visit.push_back({right, depth});
to_visit.push_back({left, depth});
to_visit.Push({right, depth});
to_visit.Push({left, depth});
} else {
to_visit.push_back({left, depth});
to_visit.push_back({right, depth});
to_visit.Push({left, depth});
to_visit.Push({right, depth});
}
};
auto push_list = [&](const std::vector<const ast::Expression*>& exprs, size_t depth) {
if (ORDER == TraverseOrder::LeftToRight) {
for (auto* expr : utils::Reverse(exprs)) {
to_visit.push_back({expr, depth});
to_visit.Push({expr, depth});
}
} else {
for (auto* expr : exprs) {
to_visit.push_back({expr, depth});
to_visit.Push({expr, depth});
}
}
};
while (!to_visit.empty()) {
auto p = to_visit.back();
to_visit.pop_back();
while (!to_visit.IsEmpty()) {
auto p = to_visit.Pop();
const ast::Expression* expr = p.expr;
if (auto* filtered = expr->template As<EXPR_TYPE>()) {