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:
parent
8fc9b86214
commit
d21e2d64ec
|
@ -97,11 +97,11 @@ class TestHelper : public ProgramBuilder {
|
|||
/// @return true if all users are as expected
|
||||
bool CheckVarUsers(const ast::Variable* var,
|
||||
utils::VectorRef<const ast::Expression*> expected_users) {
|
||||
auto& var_users = Sem().Get(var)->Users();
|
||||
if (var_users.size() != expected_users.Length()) {
|
||||
auto var_users = Sem().Get(var)->Users();
|
||||
if (var_users.Length() != expected_users.Length()) {
|
||||
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]) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -91,10 +91,10 @@ class Variable : public Castable<Variable, Node> {
|
|||
void SetInitializer(const ValueExpression* initializer) { initializer_ = initializer; }
|
||||
|
||||
/// @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
|
||||
void AddUser(const VariableUser* user) { users_.emplace_back(user); }
|
||||
void AddUser(const VariableUser* user) { users_.Push(user); }
|
||||
|
||||
private:
|
||||
const ast::Variable* const declaration_;
|
||||
|
@ -104,7 +104,7 @@ class Variable : public Castable<Variable, Node> {
|
|||
const builtin::Access access_;
|
||||
const constant::Value* constant_value_;
|
||||
const ValueExpression* initializer_ = nullptr;
|
||||
std::vector<const VariableUser*> users_;
|
||||
utils::Vector<const VariableUser*, 8> users_;
|
||||
};
|
||||
|
||||
/// LocalVariable is a function-scope variable
|
||||
|
|
Loading…
Reference in New Issue