Skip to content

Commit a21f3a7

Browse files
committed
Clean up encode_dep_graph
1 parent f3e6d88 commit a21f3a7

File tree

1 file changed

+5
-12
lines changed
  • compiler/rustc_incremental/src/persist

1 file changed

+5
-12
lines changed

compiler/rustc_incremental/src/persist/save.rs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@ fn encode_dep_graph(tcx: TyCtxt<'_>, encoder: &mut Encoder) {
153153
let total_node_count = serialized_graph.nodes.len();
154154
let total_edge_count = serialized_graph.edge_list_data.len();
155155

156-
let mut counts: FxHashMap<_, Stat> = FxHashMap::default();
156+
let mut counts: FxHashMap<_, Stat> =
157+
FxHashMap::with_capacity_and_hasher(total_node_count, Default::default());
157158

158159
for (i, &node) in serialized_graph.nodes.iter_enumerated() {
159160
let stat = counts.entry(node.kind).or_insert(Stat {
@@ -170,14 +171,6 @@ fn encode_dep_graph(tcx: TyCtxt<'_>, encoder: &mut Encoder) {
170171
let mut counts: Vec<_> = counts.values().cloned().collect();
171172
counts.sort_by_key(|s| -(s.node_counter as i64));
172173

173-
let percentage_of_all_nodes: Vec<f64> = counts
174-
.iter()
175-
.map(|s| (100.0 * (s.node_counter as f64)) / (total_node_count as f64))
176-
.collect();
177-
178-
let average_edges_per_kind: Vec<f64> =
179-
counts.iter().map(|s| (s.edge_counter as f64) / (s.node_counter as f64)).collect();
180-
181174
println!("[incremental]");
182175
println!("[incremental] DepGraph Statistics");
183176

@@ -207,13 +200,13 @@ fn encode_dep_graph(tcx: TyCtxt<'_>, encoder: &mut Encoder) {
207200
|------------------|"
208201
);
209202

210-
for (i, stat) in counts.iter().enumerate() {
203+
for stat in counts.iter() {
211204
println!(
212205
"[incremental] {:<36}|{:>16.1}% |{:>12} |{:>17.1} |",
213206
format!("{:?}", stat.kind),
214-
percentage_of_all_nodes[i],
207+
(100.0 * (stat.node_counter as f64)) / (total_node_count as f64), // percentage of all nodes
215208
stat.node_counter,
216-
average_edges_per_kind[i]
209+
(stat.edge_counter as f64) / (stat.node_counter as f64), // average edges per kind
217210
);
218211
}
219212

0 commit comments

Comments
 (0)