Patchwork D9492: copies-rust: pre-introduce a PathToken type and use it where applicable

login
register
mail settings
Submitter phabricator
Date Dec. 2, 2020, 4:02 p.m.
Message ID <differential-rev-PHID-DREV-46mdivxjt4yqruiun6bx-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47774/
State Superseded
Headers show

Comments

phabricator - Dec. 2, 2020, 4:02 p.m.
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D9492

AFFECTED FILES
  rust/hg-core/src/copy_tracing.rs

CHANGE DETAILS




To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/rust/hg-core/src/copy_tracing.rs b/rust/hg-core/src/copy_tracing.rs
--- a/rust/hg-core/src/copy_tracing.rs
+++ b/rust/hg-core/src/copy_tracing.rs
@@ -12,17 +12,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>);
@@ -500,7 +502,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)
@@ -558,10 +560,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()))
         };
 
@@ -635,7 +637,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 {