changeset 44548:b8ba46c97cdd

rust-status: wrap `stat_dmap_entries` to ease profiling Differential Revision: https://phab.mercurial-scm.org/D8250
author Raphaël Gomès <rgomes@octobus.net>
date Fri, 06 Mar 2020 17:51:03 +0100
parents 5f6a504dc0bd
children fe7d2cf0b429
files rust/hg-core/src/dirstate/status.rs
diffstat 1 files changed, 16 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/rust/hg-core/src/dirstate/status.rs	Fri Mar 06 17:48:30 2020 +0100
+++ b/rust/hg-core/src/dirstate/status.rs	Fri Mar 06 17:51:03 2020 +0100
@@ -508,6 +508,21 @@
     })
 }
 
+/// 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<Path> + 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<Cow<'a, HgPath>>,
     pub added: Vec<Cow<'a, HgPath>>,
@@ -766,10 +781,7 @@
         } 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);
         }
     }