changeset 49995:b6dc4802e7ef

rust: don't use a reference to a `Cow` This was caught by `clippy`.
author Raphaël Gomès <rgomes@octobus.net>
date Mon, 09 Jan 2023 18:25:24 +0100
parents 5fff90c7ea9d
children 547d6817e0c3
files rust/hg-core/src/dirstate_tree/dirstate_map.rs
diffstat 1 files changed, 10 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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)
             }))