rust: don't use a reference to a `Cow`
authorRaphaël Gomès <rgomes@octobus.net>
Mon, 09 Jan 2023 18:25:24 +0100
changeset 49922 b6dc4802e7ef
parent 49921 5fff90c7ea9d
child 49923 547d6817e0c3
rust: don't use a reference to a `Cow` This was caught by `clippy`.
rust/hg-core/src/dirstate_tree/dirstate_map.rs
--- a/rust/hg-core/src/dirstate_tree/dirstate_map.rs	Mon Jan 09 18:22:46 2023 +0100
+++ b/rust/hg-core/src/dirstate_tree/dirstate_map.rs	Mon Jan 09 18:25:24 2023 +0100
@@ -912,7 +912,7 @@
         })
     }
 
-    fn count_dropped_path(unreachable_bytes: &mut u32, path: &Cow<HgPath>) {
+    fn count_dropped_path(unreachable_bytes: &mut u32, path: Cow<HgPath>) {
         if let Cow::Borrowed(path) = path {
             *unreachable_bytes += path.len() as u32
         }
@@ -1124,7 +1124,10 @@
                 }
                 let mut had_copy_source = false;
                 if let Some(source) = &node.copy_source {
-                    DirstateMap::count_dropped_path(unreachable_bytes, source);
+                    DirstateMap::count_dropped_path(
+                        unreachable_bytes,
+                        Cow::Borrowed(source),
+                    );
                     had_copy_source = true;
                     node.copy_source = None
                 }
@@ -1144,7 +1147,7 @@
                     nodes.remove_entry(first_path_component).unwrap();
                 DirstateMap::count_dropped_path(
                     unreachable_bytes,
-                    key.full_path(),
+                    Cow::Borrowed(key.full_path()),
                 )
             }
             Ok(Some((dropped, remove)))
@@ -1343,7 +1346,10 @@
                     *count = count
                         .checked_sub(1)
                         .expect("nodes_with_copy_source_count should be >= 0");
-                    DirstateMap::count_dropped_path(unreachable_bytes, source);
+                    DirstateMap::count_dropped_path(
+                        unreachable_bytes,
+                        Cow::Borrowed(source),
+                    );
                 }
                 node.copy_source.take().map(Cow::into_owned)
             }))