changeset 51292:c4cbb515b006

rust-clippy: apply some more trivial fixes All of these were hinted at by clippy and make the code simpler.
author Raphaël Gomès <rgomes@octobus.net>
date Wed, 20 Dec 2023 14:59:31 +0100
parents eab5b061cd48
children 79cd29d598af
files rust/hg-core/src/revlog/index.rs rust/hg-cpython/src/ancestors.rs
diffstat 2 files changed, 14 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/rust/hg-core/src/revlog/index.rs	Wed Dec 20 14:58:36 2023 +0100
+++ b/rust/hg-core/src/revlog/index.rs	Wed Dec 20 14:59:31 2023 +0100
@@ -320,7 +320,7 @@
         rev: BaseRevision,
         value: BaseRevision,
     ) -> Result<(), RevlogError> {
-        let all_values = self.entry(rev).or_insert_with(HashSet::new);
+        let all_values = self.entry(rev).or_default();
         all_values.insert(value);
         Ok(())
     }
@@ -941,7 +941,7 @@
         let last_entry = &self.get_entry(revs[revs.len() - 1]).unwrap();
         let end = last_entry.c_start() + last_entry.compressed_len() as u64;
         let first_rev = revs.iter().find(|r| r.0 != NULL_REVISION.0).unwrap();
-        let start = if (*first_rev).0 == 0 {
+        let start = if first_rev.0 == 0 {
             0
         } else {
             self.get_entry(*first_rev).unwrap().c_start()
@@ -1822,28 +1822,28 @@
         pub fn build(&self) -> Vec<u8> {
             let mut bytes = Vec::with_capacity(INDEX_ENTRY_SIZE);
             if self.is_first {
-                bytes.extend(&match (self.is_general_delta, self.is_inline) {
+                bytes.extend(match (self.is_general_delta, self.is_inline) {
                     (false, false) => [0u8, 0],
                     (false, true) => [0u8, 1],
                     (true, false) => [0u8, 2],
                     (true, true) => [0u8, 3],
                 });
-                bytes.extend(&self.version.to_be_bytes());
+                bytes.extend(self.version.to_be_bytes());
                 // Remaining offset bytes.
-                bytes.extend(&[0u8; 2]);
+                bytes.extend([0u8; 2]);
             } else {
                 // Offset stored on 48 bits (6 bytes)
                 bytes.extend(&(self.offset as u64).to_be_bytes()[2..]);
             }
-            bytes.extend(&[0u8; 2]); // Revision flags.
-            bytes.extend(&(self.compressed_len as u32).to_be_bytes());
-            bytes.extend(&(self.uncompressed_len as u32).to_be_bytes());
+            bytes.extend([0u8; 2]); // Revision flags.
+            bytes.extend((self.compressed_len as u32).to_be_bytes());
+            bytes.extend((self.uncompressed_len as u32).to_be_bytes());
             bytes.extend(
-                &self.base_revision_or_base_of_delta_chain.0.to_be_bytes(),
+                self.base_revision_or_base_of_delta_chain.0.to_be_bytes(),
             );
-            bytes.extend(&self.link_revision.0.to_be_bytes());
-            bytes.extend(&self.p1.0.to_be_bytes());
-            bytes.extend(&self.p2.0.to_be_bytes());
+            bytes.extend(self.link_revision.0.to_be_bytes());
+            bytes.extend(self.p1.0.to_be_bytes());
+            bytes.extend(self.p2.0.to_be_bytes());
             bytes.extend(self.node.as_bytes());
             bytes.extend(vec![0u8; 12]);
             bytes
--- a/rust/hg-cpython/src/ancestors.rs	Wed Dec 20 14:58:36 2023 +0100
+++ b/rust/hg-cpython/src/ancestors.rs	Wed Dec 20 14:59:31 2023 +0100
@@ -177,7 +177,7 @@
         let inner: &RefCell<VCGLazyAncestors<PySharedIndex>> =
             &*unsafe { leaked.try_borrow(py)? };
         let inner_mut: &mut VCGLazyAncestors<PySharedIndex> =
-            &mut *inner.borrow_mut();
+            &mut inner.borrow_mut();
         inner_mut.contains(rev.0)
             .map_err(|e| GraphError::pynew_from_vcsgraph(py, e))
     }
@@ -335,7 +335,7 @@
                                                self.index(py).clone_ref(py))?;
             // Safety: we don't leak the "faked" reference out of `UnsafePyLeaked`
             let index = &*unsafe { leaked.try_borrow(py)? };
-            rev_pyiter_collect(py, &revs, &*index)?
+            rev_pyiter_collect(py, &revs, index)?
         };
 
         let mut leaked = self.inner(py).borrow_mut();