From 4ec74df81f9a56e2eef5defea6edaa9eecd4fd10 Mon Sep 17 00:00:00 2001 From: John Kåre Alsaker Date: Tue, 22 Apr 2025 03:43:10 +0200 Subject: Use `IndexVec::from_elem_n` --- compiler/rustc_query_system/src/dep_graph/serialized.rs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'compiler/rustc_query_system/src') 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 = (0..node_count) - .map(|_| DepNode { - kind: D::DEP_KIND_NULL, - hash: PackedFingerprint::from(Fingerprint::ZERO), - }) - .collect(); - let mut fingerprints: IndexVec = - (0..node_count).map(|_| Fingerprint::ZERO).collect(); - let mut edge_list_indices: IndexVec = - (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 -- cgit 1.4.1-3-g733a5