changeset 46152:e166e8a035a7

copies-rust: use the entry API to overwrite deleted entry This is more efficient, more idiomatic and more compact. The main motivation for this change is to cleanup that area before start to do "overwrite" tracking. Such tracking will ultimately help to avoid costly is_ancestors call when merging changeset. Differential Revision: https://phab.mercurial-scm.org/D9494
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 02 Dec 2020 10:51:40 +0100
parents c6bc77f7e593
children 0a721fc457bf
files rust/hg-core/src/copy_tracing.rs
diffstat 1 files changed, 4 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/rust/hg-core/src/copy_tracing.rs	Sat Apr 25 12:37:46 2020 +0200
+++ b/rust/hg-core/src/copy_tracing.rs	Wed Dec 02 10:51:40 2020 +0100
@@ -523,13 +523,10 @@
                 // propagate this information when merging two
                 // TimeStampedPathCopies object.
                 let deleted = path_map.tokenize(deleted_path);
-                if copies.contains_key(&deleted) {
-                    let ttpc = TimeStampedPathCopy {
-                        rev: current_rev,
-                        path: None,
-                    };
-                    copies.insert(deleted, ttpc);
-                }
+                copies.entry(deleted).and_modify(|old| {
+                    old.rev = current_rev;
+                    old.path = None;
+                });
             }
         }
     }