]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc/dep_graph/query.rs
rustc: Preallocate when building the dep graph
[rust.git] / src / librustc / dep_graph / query.rs
index 283da1050aedc8393c1d6ca7057ba5d39f846d3a..ea83a4f8b3104dd2de1113fa6eba381d1d043444 100644 (file)
@@ -22,11 +22,10 @@ impl DepGraphQuery {
     pub fn new(nodes: &[DepNode],
                edges: &[(DepNode, DepNode)])
                -> DepGraphQuery {
-        let mut graph = Graph::new();
+        let mut graph = Graph::with_capacity(nodes.len(), edges.len());
         let mut indices = FxHashMap();
         for node in nodes {
-            indices.insert(node.clone(), graph.next_node_index());
-            graph.add_node(node.clone());
+            indices.insert(node.clone(), graph.add_node(node.clone()));
         }
 
         for &(ref source, ref target) in edges {