# HG changeset patch # User Pierre-Yves David # Date 2020-12-02 09:51:40 # Node ID e166e8a035a782be80c0f2b164ccae2ea69a0c93 # Parent c6bc77f7e593a882d026264d9b28be783f1e0d42 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 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 @@ -523,13 +523,10 @@ fn add_from_changes( // 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; + }); } } }