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
--- 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;
+ });
}
}
}