@@ -153,7 +153,8 @@ fn encode_dep_graph(tcx: TyCtxt<'_>, encoder: &mut Encoder) {
153
153
let total_node_count = serialized_graph. nodes . len ( ) ;
154
154
let total_edge_count = serialized_graph. edge_list_data . len ( ) ;
155
155
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 ( ) ) ;
157
158
158
159
for ( i, & node) in serialized_graph. nodes . iter_enumerated ( ) {
159
160
let stat = counts. entry ( node. kind ) . or_insert ( Stat {
@@ -170,14 +171,6 @@ fn encode_dep_graph(tcx: TyCtxt<'_>, encoder: &mut Encoder) {
170
171
let mut counts: Vec < _ > = counts. values ( ) . cloned ( ) . collect ( ) ;
171
172
counts. sort_by_key ( |s| -( s. node_counter as i64 ) ) ;
172
173
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
-
181
174
println ! ( "[incremental]" ) ;
182
175
println ! ( "[incremental] DepGraph Statistics" ) ;
183
176
@@ -207,13 +200,13 @@ fn encode_dep_graph(tcx: TyCtxt<'_>, encoder: &mut Encoder) {
207
200
|------------------|"
208
201
) ;
209
202
210
- for ( i , stat) in counts. iter ( ) . enumerate ( ) {
203
+ for stat in counts. iter ( ) {
211
204
println ! (
212
205
"[incremental] {:<36}|{:>16.1}% |{:>12} |{:>17.1} |" ,
213
206
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
215
208
stat. node_counter,
216
- average_edges_per_kind [ i ]
209
+ ( stat . edge_counter as f64 ) / ( stat . node_counter as f64 ) , // average edges per kind
217
210
) ;
218
211
}
219
212
0 commit comments