tint/resolver: Pre-allocate containers

Reserve the memory for the dependency graph containers.
Reduces expensive heap allocations.

Change-Id: Ia650fcb9f9e461afb8b240c9472a9a478a9968d1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98081
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
diff --git a/src/tint/resolver/dependency_graph.cc b/src/tint/resolver/dependency_graph.cc
index 2ddcaaa..6dd35a5 100644
--- a/src/tint/resolver/dependency_graph.cc
+++ b/src/tint/resolver/dependency_graph.cc
@@ -489,6 +489,10 @@
     /// #diagnostics.
     /// @returns true if analysis found no errors, otherwise false.
     bool Run(const ast::Module& module) {
+        // Reserve container memory
+        graph_.resolved_symbols.reserve(module.GlobalDeclarations().Length());
+        sorted_.reserve(module.GlobalDeclarations().Length());
+
         // Collect all the named globals from the AST module
         GatherGlobals(module);