Skip to content

Commit d1aea27

Browse files
committed
Use IndexVec::from_elem_n
1 parent 6bd3f14 commit d1aea27

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

compiler/rustc_query_system/src/dep_graph/serialized.rs

+7-10
Original file line numberDiff line numberDiff line change
@@ -200,16 +200,13 @@ impl SerializedDepGraph {
200200

201201
let graph_bytes = d.len() - (2 * IntEncodedWithFixedSize::ENCODED_SIZE) - d.position();
202202

203-
let mut nodes: IndexVec<SerializedDepNodeIndex, _> = (0..node_count)
204-
.map(|_| DepNode {
205-
kind: D::DEP_KIND_NULL,
206-
hash: PackedFingerprint::from(Fingerprint::ZERO),
207-
})
208-
.collect();
209-
let mut fingerprints: IndexVec<SerializedDepNodeIndex, _> =
210-
(0..node_count).map(|_| Fingerprint::ZERO).collect();
211-
let mut edge_list_indices: IndexVec<SerializedDepNodeIndex, _> =
212-
(0..node_count).map(|_| EdgeHeader { repr: 0, edges: 0 }).collect();
203+
let mut nodes = IndexVec::from_elem_n(
204+
DepNode { kind: D::DEP_KIND_NULL, hash: PackedFingerprint::from(Fingerprint::ZERO) },
205+
node_count,
206+
);
207+
let mut fingerprints = IndexVec::from_elem_n(Fingerprint::ZERO, node_count);
208+
let mut edge_list_indices =
209+
IndexVec::from_elem_n(EdgeHeader { repr: 0, edges: 0 }, node_count);
213210

214211
// This estimation assumes that all of the encoded bytes are for the edge lists or for the
215212
// fixed-size node headers. But that's not necessarily true; if any edge list has a length

0 commit comments

Comments
 (0)