about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJohn Kåre Alsaker <john.kare.alsaker@gmail.com>2025-04-22 03:43:10 +0200
committerJohn Kåre Alsaker <john.kare.alsaker@gmail.com>2025-04-22 16:57:28 +0200
commit4ec74df81f9a56e2eef5defea6edaa9eecd4fd10 (patch)
treead681da265fbe7fd7358f144e1e38c32614b530f
parentc6735f92c1b7e24a434d3882d5e2dd716cbbb0d3 (diff)
downloadrust-4ec74df81f9a56e2eef5defea6edaa9eecd4fd10.tar.gz
rust-4ec74df81f9a56e2eef5defea6edaa9eecd4fd10.zip
Use `IndexVec::from_elem_n`
-rw-r--r--compiler/rustc_query_system/src/dep_graph/serialized.rs17
1 files changed, 7 insertions, 10 deletions
diff --git a/compiler/rustc_query_system/src/dep_graph/serialized.rs b/compiler/rustc_query_system/src/dep_graph/serialized.rs
index cfea43d62e5..9dabb26e8b2 100644
--- a/compiler/rustc_query_system/src/dep_graph/serialized.rs
+++ b/compiler/rustc_query_system/src/dep_graph/serialized.rs
@@ -200,16 +200,13 @@ impl SerializedDepGraph {
 
         let graph_bytes = d.len() - (2 * IntEncodedWithFixedSize::ENCODED_SIZE) - d.position();
 
-        let mut nodes: IndexVec<SerializedDepNodeIndex, _> = (0..node_count)
-            .map(|_| DepNode {
-                kind: D::DEP_KIND_NULL,
-                hash: PackedFingerprint::from(Fingerprint::ZERO),
-            })
-            .collect();
-        let mut fingerprints: IndexVec<SerializedDepNodeIndex, _> =
-            (0..node_count).map(|_| Fingerprint::ZERO).collect();
-        let mut edge_list_indices: IndexVec<SerializedDepNodeIndex, _> =
-            (0..node_count).map(|_| EdgeHeader { repr: 0, edges: 0 }).collect();
+        let mut nodes = IndexVec::from_elem_n(
+            DepNode { kind: D::DEP_KIND_NULL, hash: PackedFingerprint::from(Fingerprint::ZERO) },
+            node_count,
+        );
+        let mut fingerprints = IndexVec::from_elem_n(Fingerprint::ZERO, node_count);
+        let mut edge_list_indices =
+            IndexVec::from_elem_n(EdgeHeader { repr: 0, edges: 0 }, node_count);
 
         // This estimation assumes that all of the encoded bytes are for the edge lists or for the
         // fixed-size node headers. But that's not necessarily true; if any edge list has a length