1
Fork 0

Sort Generator print-type-sizes according to their yield points

Especially when trying to diagnose runaway future sizes, it might be
more intuitive to sort the variants according to the control flow
(aka their yield points) rather than the size of the variants.
This commit is contained in:
Arpad Borsos 2023-02-05 16:26:51 +01:00
parent 7f97aeaf73
commit dae00152e7
No known key found for this signature in database
GPG key ID: FC7BCA77824B3298
6 changed files with 25 additions and 12 deletions

View file

@ -84,7 +84,11 @@ impl CodeStats {
// Sort variants so the largest ones are shown first. A stable sort is
// used here so that source code order is preserved for all variants
// that have the same size.
variants.sort_by(|info1, info2| info2.size.cmp(&info1.size));
// Except for Generators, whose variants are already sorted according to
// their yield points in `variant_info_for_generator`.
if kind != DataTypeKind::Generator {
variants.sort_by(|info1, info2| info2.size.cmp(&info1.size));
}
let info = TypeSizeInfo {
kind,
type_description: type_desc.to_string(),