# HG changeset patch # User Raphaël Gomès # Date 2020-03-06 16:51:03 # Node ID b8ba46c97cdd3884b5ce2d3fbd14d93b5273020a # Parent 5f6a504dc0bd74c37c1d4b10a97855223bcfba57 rust-status: wrap `stat_dmap_entries` to ease profiling Differential Revision: https://phab.mercurial-scm.org/D8250 diff --git a/rust/hg-core/src/dirstate/status.rs b/rust/hg-core/src/dirstate/status.rs --- a/rust/hg-core/src/dirstate/status.rs +++ b/rust/hg-core/src/dirstate/status.rs @@ -508,6 +508,21 @@ fn stat_dmap_entries( }) } +/// This takes a mutable reference to the results to account for the `extend` +/// in timings +fn extend_from_dmap<'a>( + dmap: &'a DirstateMap, + root_dir: impl AsRef + Sync + Send, + options: StatusOptions, + results: &mut Vec<(Cow<'a, HgPath>, Dispatch)>, +) { + results.par_extend( + stat_dmap_entries(dmap, root_dir, options) + .flatten() + .map(|(filename, dispatch)| (Cow::Borrowed(filename), dispatch)), + ); +} + pub struct DirstateStatus<'a> { pub modified: Vec>, pub added: Vec>, @@ -766,10 +781,7 @@ pub fn status<'a: 'c, 'b: 'c, 'c>( } else { // We may not have walked the full directory tree above, so stat // and check everything we missed. - let stat_results = stat_dmap_entries(&dmap, root_dir, options); - results.par_extend(stat_results.flatten().map( - |(filename, dispatch)| (Cow::Borrowed(filename), dispatch), - )); + extend_from_dmap(&dmap, root_dir, options, &mut results); } }