tint: Optimization: Pre-allocate the ast -> sem map.
Change-Id: I674fe31786b08153509b470d14844d50cb7c3d9c Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96143 Commit-Queue: Ben Clayton <bclayton@google.com> Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
parent
59e640b208
commit
b71bcdd45e
|
@ -103,6 +103,9 @@ bool Resolver::Resolve() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Pre-allocate the ast -> sem map with the total number of AST nodes.
|
||||||
|
builder_->Sem().Reserve(builder_->ASTNodes().Count());
|
||||||
|
|
||||||
if (!DependencyGraph::Build(builder_->AST(), builder_->Symbols(), builder_->Diagnostics(),
|
if (!DependencyGraph::Build(builder_->AST(), builder_->Symbols(), builder_->Diagnostics(),
|
||||||
dependencies_)) {
|
dependencies_)) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -35,7 +35,7 @@ class Info {
|
||||||
/// Placeholder type used by Get() to provide a default value for EXPLICIT_SEM
|
/// Placeholder type used by Get() to provide a default value for EXPLICIT_SEM
|
||||||
using InferFromAST = std::nullptr_t;
|
using InferFromAST = std::nullptr_t;
|
||||||
|
|
||||||
/// Resolves to the return type of the Get() method given the desired sementic
|
/// Resolves to the return type of the Get() method given the desired semantic
|
||||||
/// type and AST type.
|
/// type and AST type.
|
||||||
template <typename SEM, typename AST>
|
template <typename SEM, typename AST>
|
||||||
using GetResultType =
|
using GetResultType =
|
||||||
|
@ -55,6 +55,10 @@ class Info {
|
||||||
/// @return this Program
|
/// @return this Program
|
||||||
Info& operator=(Info&& rhs);
|
Info& operator=(Info&& rhs);
|
||||||
|
|
||||||
|
/// Pre-allocates the AST -> semantic node map to fit at least the given number of nodes.
|
||||||
|
/// @param num_ast_nodes the number of AST nodes to pre-allocate the map for.
|
||||||
|
void Reserve(size_t num_ast_nodes) { map_.reserve(num_ast_nodes); }
|
||||||
|
|
||||||
/// Get looks up the semantic information for the AST node `node`.
|
/// Get looks up the semantic information for the AST node `node`.
|
||||||
/// @param ast_node the AST node
|
/// @param ast_node the AST node
|
||||||
/// @returns a pointer to the semantic node if found, otherwise nullptr
|
/// @returns a pointer to the semantic node if found, otherwise nullptr
|
||||||
|
|
Loading…
Reference in New Issue