Move iter_results to dyn FnMut rather than a generic

This means that we're no longer generating the iteration/locking code for each
invocation site of iter_results, rather just once per query.

This is a 15% win in instruction counts when compiling the rustc_query_impl crate.
This commit is contained in:
Mark Rousskov
2021-04-29 10:23:17 -04:00
parent c488f15700
commit a1d7367429
5 changed files with 53 additions and 47 deletions

View File

@@ -50,13 +50,12 @@ where
key_type: type_name::<C::Key>(),
value_size: mem::size_of::<C::Value>(),
value_type: type_name::<C::Value>(),
entry_count: map.iter_results(|results| results.count()),
entry_count: 0,
local_def_id_keys: None,
};
map.iter_results(|results| {
for (key, _, _) in results {
key.key_stats(&mut stats)
}
map.iter_results(&mut |key, _, _| {
stats.entry_count += 1;
key.key_stats(&mut stats)
});
stats
}