Compute total_problems rather than asking for it

This commit is contained in:
Richard Feldman 2023-10-14 21:18:42 -04:00
parent 97f252c68b
commit eb135637ef
No known key found for this signature in database
GPG key ID: F1F21AA5B1D9E43B
4 changed files with 11 additions and 21 deletions

View file

@ -46,13 +46,12 @@ impl Problems {
1 => "warning",
_ => "warnings",
},
total_time.as_millis(),
total_time.as_millis()
);
}
}
pub fn report_problems(
total_problems: usize,
sources: &MutMap<ModuleId, (PathBuf, Box<str>)>,
interns: &Interns,
can_problems: &mut MutMap<ModuleId, Vec<roc_problem::can::Problem>>,
@ -60,7 +59,17 @@ pub fn report_problems(
) -> Problems {
use crate::report::{can_problem, type_problem, Report, RocDocAllocator, DEFAULT_PALETTE};
use roc_problem::Severity::*;
let palette = DEFAULT_PALETTE;
let mut total_problems = 0;
for problems in can_problems.values() {
total_problems += problems.len();
}
for problems in type_problems.values() {
total_problems += problems.len();
}
// This will often over-allocate total memory, but it means we definitely
// never need to re-allocate either the warnings or the errors vec!