Skip to content

Commit da5b805

Browse files
committed
outline summary code
1 parent 4a87035 commit da5b805

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

analyze/analyses/monos/mod.rs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -128,19 +128,11 @@ fn process_monomorphizations(monos_map: MonosMap, opts: &opt::Monos) -> Vec<Mono
128128
monos
129129
}
130130

131-
/// Find bloaty monomorphizations of generic functions.
132-
pub fn monos(
133-
items: &mut ir::Items,
134-
opts: &opt::Monos,
135-
) -> Result<Box<dyn traits::Emit>, traits::Error> {
136-
// Collect the options that will be needed.
131+
/// Adds entries to summarize remaining rows that will be truncated, and
132+
/// totals for the entire set of monomorphizations.
133+
fn add_stats(mut monos: Vec<MonosEntry>, opts: &opt::Monos) -> Vec<MonosEntry> {
137134
let max_generics = opts.max_generics() as usize;
138135

139-
// Collect the monomorphizations of generic functions into a map, then
140-
// process the entries and sort the resulting vector.
141-
let monos_map = collect_monomorphizations(&items);
142-
let mut monos = process_monomorphizations(monos_map, &opts);
143-
144136
// Create an entry to represent the remaining rows that will be truncated.
145137
let (rem_cnt, rem_size, rem_savings) = summarize_entries(monos.iter().skip(max_generics));
146138
let remaining = MonosEntry {
@@ -165,5 +157,16 @@ pub fn monos(
165157
monos.push(remaining);
166158
}
167159
monos.push(total);
160+
monos
161+
}
162+
163+
/// Find bloaty monomorphizations of generic functions.
164+
pub fn monos(
165+
items: &mut ir::Items,
166+
opts: &opt::Monos,
167+
) -> Result<Box<dyn traits::Emit>, traits::Error> {
168+
let monos_map = collect_monomorphizations(&items);
169+
let mut monos = process_monomorphizations(monos_map, &opts);
170+
monos = add_stats(monos, &opts);
168171
Ok(Box::new(Monos { monos }) as Box<_>)
169172
}

0 commit comments

Comments
 (0)