changeset 46130:818502d2f5e3

copies-rust: pre-introduce a PathToken type and use it where applicable Handling string all the time is quite slow. So we are about to use more efficient "token". We do some of the churn early to clarify the next changesets. Differential Revision: https://phab.mercurial-scm.org/D9492
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Tue, 21 Apr 2020 15:13:13 +0200
parents c94d013e2299
children 60677eca7434
files rust/hg-core/src/copy_tracing.rs
diffstat 1 files changed, 8 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/rust/hg-core/src/copy_tracing.rs	Sat Nov 21 09:40:52 2020 +0100
+++ b/rust/hg-core/src/copy_tracing.rs	Tue Apr 21 15:13:13 2020 +0200
@@ -11,17 +11,19 @@
 
 pub type PathCopies = HashMap<HgPathBuf, HgPathBuf>;
 
+type PathToken = HgPathBuf;
+
 #[derive(Clone, Debug, PartialEq)]
 struct TimeStampedPathCopy {
     /// revision at which the copy information was added
     rev: Revision,
     /// the copy source, (Set to None in case of deletion of the associated
     /// key)
-    path: Option<HgPathBuf>,
+    path: Option<PathToken>,
 }
 
 /// maps CopyDestination to Copy Source (+ a "timestamp" for the operation)
-type TimeStampedPathCopies = OrdMap<HgPathBuf, TimeStampedPathCopy>;
+type TimeStampedPathCopies = OrdMap<PathToken, TimeStampedPathCopy>;
 
 /// hold parent 1, parent 2 and relevant files actions.
 pub type RevInfo<'a> = (Revision, Revision, ChangedFiles<'a>);
@@ -467,7 +469,7 @@
     // actively working on this code. Feel free to re-inline it once this
     // code is more settled.
     let mut cmp_value =
-        |dest: &HgPathBuf,
+        |dest: &PathToken,
          src_minor: &TimeStampedPathCopy,
          src_major: &TimeStampedPathCopy| {
             compare_value(changes, oracle, dest, src_minor, src_major)
@@ -525,10 +527,10 @@
         let mut override_minor = Vec::new();
         let mut override_major = Vec::new();
 
-        let mut to_major = |k: &HgPathBuf, v: &TimeStampedPathCopy| {
+        let mut to_major = |k: &PathToken, v: &TimeStampedPathCopy| {
             override_major.push((k.clone(), v.clone()))
         };
-        let mut to_minor = |k: &HgPathBuf, v: &TimeStampedPathCopy| {
+        let mut to_minor = |k: &PathToken, v: &TimeStampedPathCopy| {
             override_minor.push((k.clone(), v.clone()))
         };
 
@@ -602,7 +604,7 @@
 fn compare_value<A: Fn(Revision, Revision) -> bool>(
     changes: &ChangedFiles,
     oracle: &mut AncestorOracle<A>,
-    dest: &HgPathBuf,
+    dest: &PathToken,
     src_minor: &TimeStampedPathCopy,
     src_major: &TimeStampedPathCopy,
 ) -> MergePick {