From 9ebed7399274b74f70a376328fb1f95b585a93b5 Mon Sep 17 00:00:00 2001 From: james7132 Date: Tue, 19 Mar 2024 22:15:33 -0700 Subject: [PATCH] Fix clippy --- src/block/avx2.rs | 7 +------ src/block/mod.rs | 2 ++ src/lib.rs | 21 +++++++++------------ 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/src/block/avx2.rs b/src/block/avx2.rs index 00b835a..4258a5a 100644 --- a/src/block/avx2.rs +++ b/src/block/avx2.rs @@ -2,12 +2,7 @@ use core::arch::x86::*; #[cfg(target_arch = "x86_64")] use core::arch::x86_64::*; -use core::{ - cmp::Ordering, - hash::{Hash, Hasher}, - iter::Iterator, - ops::{BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Not}, -}; +use core::ops::{BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Not}; #[derive(Copy, Clone, Debug)] #[repr(transparent)] diff --git a/src/block/mod.rs b/src/block/mod.rs index be64af9..52158ce 100644 --- a/src/block/mod.rs +++ b/src/block/mod.rs @@ -1,3 +1,5 @@ +#![allow(clippy::undocumented_unsafe_blocks)] + use core::cmp::Ordering; use core::hash::{Hash, Hasher}; diff --git a/src/lib.rs b/src/lib.rs index c33c50b..7ef85b3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -681,13 +681,12 @@ impl FixedBitSet { pub fn union_count(&self, other: &FixedBitSet) -> usize { let me = self.as_slice(); let other = other.as_slice(); - let mut count = Self::batch_count_ones(me.iter().zip(other.iter()).map(|(x, y)| (*x | *y))); - if other.len() > me.len() { - count += Self::batch_count_ones(other[me.len()..].iter().copied()); - } else if self.len() > other.len() { - count += Self::batch_count_ones(me[other.len()..].iter().copied()); + let count = Self::batch_count_ones(me.iter().zip(other.iter()).map(|(x, y)| (*x | *y))); + match other.len().cmp(&me.len()) { + Ordering::Greater => count + Self::batch_count_ones(other[me.len()..].iter().copied()), + Ordering::Less => count + Self::batch_count_ones(me[other.len()..].iter().copied()), + Ordering::Equal => count, } - count } /// Computes how many bits would be set in the intersection between two bitsets. @@ -730,12 +729,10 @@ impl FixedBitSet { let me = self.as_slice(); let other = other.as_slice(); let count = Self::batch_count_ones(me.iter().zip(other.iter()).map(|(x, y)| (*x ^ *y))); - if other.len() > me.len() { - count + Self::batch_count_ones(other[me.len()..].iter().copied()) - } else if me.len() > other.len() { - count + Self::batch_count_ones(me[other.len()..].iter().copied()) - } else { - count + match other.len().cmp(&me.len()) { + Ordering::Greater => count + Self::batch_count_ones(other[me.len()..].iter().copied()), + Ordering::Less => count + Self::batch_count_ones(me[other.len()..].iter().copied()), + Ordering::Equal => count, } }