Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This is not done for the `dirstate-tree` feature, since it lacks `iter_mut`.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/hg-core/src/dirstate/parsers.rs

CHANGE DETAILS

diff --git a/rust/hg-core/src/dirstate/parsers.rs 
b/rust/hg-core/src/dirstate/parsers.rs
--- a/rust/hg-core/src/dirstate/parsers.rs
+++ b/rust/hg-core/src/dirstate/parsers.rs
@@ -107,12 +107,11 @@
     let expected_size = expected_size + PARENT_SIZE * 2;
 
     let mut packed = Vec::with_capacity(expected_size);
-    let mut new_state_map = vec![];
 
     packed.extend(&parents.p1);
     packed.extend(&parents.p2);
 
-    for (filename, entry) in state_map.iter() {
+    for (filename, entry) in state_map.iter_mut() {
         let new_filename = filename.to_owned();
         let mut new_mtime: i32 = entry.mtime;
         if entry.state == EntryState::Normal && entry.mtime == now {
@@ -126,13 +125,10 @@
             // contents of the file if the size is the same. This prevents
             // mistakenly treating such files as clean.
             new_mtime = -1;
-            new_state_map.push((
-                filename.to_owned(),
-                DirstateEntry {
-                    mtime: new_mtime,
-                    ..*entry
-                },
-            ));
+            *entry = DirstateEntry {
+                mtime: new_mtime,
+                ..*entry
+            };
         }
         let mut new_filename = new_filename.into_vec();
         if let Some(copy) = copy_map.get(filename) {
@@ -152,8 +148,6 @@
         return Err(DirstatePackError::BadSize(expected_size, packed.len()));
     }
 
-    state_map.extend(new_state_map);
-
     Ok(packed)
 }
 /// `now` is the duration in seconds since the Unix epoch



To: Alphare, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to