Convert VariableUser vector over to utils::Vector.

This vector was causing a lot of small allocations to happen, this CL
converts over to a utils::Vector to take advantage of the better
allocation strategy

Change-Id: Id740bd2a50a8d0bdd84f4b6e7c7ad4607436c7f4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/127500
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
dan sinclair 2023-04-19 15:06:24 +00:00 committed by Dawn LUCI CQ
parent 8fc9b86214
commit d21e2d64ec
2 changed files with 6 additions and 6 deletions

View File

@ -97,11 +97,11 @@ class TestHelper : public ProgramBuilder {
/// @return true if all users are as expected /// @return true if all users are as expected
bool CheckVarUsers(const ast::Variable* var, bool CheckVarUsers(const ast::Variable* var,
utils::VectorRef<const ast::Expression*> expected_users) { utils::VectorRef<const ast::Expression*> expected_users) {
auto& var_users = Sem().Get(var)->Users(); auto var_users = Sem().Get(var)->Users();
if (var_users.size() != expected_users.Length()) { if (var_users.Length() != expected_users.Length()) {
return false; return false;
} }
for (size_t i = 0; i < var_users.size(); i++) { for (size_t i = 0; i < var_users.Length(); i++) {
if (var_users[i]->Declaration() != expected_users[i]) { if (var_users[i]->Declaration() != expected_users[i]) {
return false; return false;
} }

View File

@ -91,10 +91,10 @@ class Variable : public Castable<Variable, Node> {
void SetInitializer(const ValueExpression* initializer) { initializer_ = initializer; } void SetInitializer(const ValueExpression* initializer) { initializer_ = initializer; }
/// @returns the expressions that use the variable /// @returns the expressions that use the variable
const std::vector<const VariableUser*>& Users() const { return users_; } utils::VectorRef<const VariableUser*> Users() const { return users_; }
/// @param user the user to add /// @param user the user to add
void AddUser(const VariableUser* user) { users_.emplace_back(user); } void AddUser(const VariableUser* user) { users_.Push(user); }
private: private:
const ast::Variable* const declaration_; const ast::Variable* const declaration_;
@ -104,7 +104,7 @@ class Variable : public Castable<Variable, Node> {
const builtin::Access access_; const builtin::Access access_;
const constant::Value* constant_value_; const constant::Value* constant_value_;
const ValueExpression* initializer_ = nullptr; const ValueExpression* initializer_ = nullptr;
std::vector<const VariableUser*> users_; utils::Vector<const VariableUser*, 8> users_;
}; };
/// LocalVariable is a function-scope variable /// LocalVariable is a function-scope variable