Skip to content

Commit 47a2e40

Browse files
committed
Make clippy happy
1 parent df66482 commit 47a2e40

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

src/distance/hamming.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ pub fn hamming_bitwise_fast(u: &[u8], v: &[u8]) -> f32 {
7070
})
7171
.sum::<u32>();
7272

73-
if u.len() % CHUNK_SIZE != 0 {
73+
if !u.len().is_multiple_of(CHUNK_SIZE) {
7474
distance += u
7575
.chunks_exact(CHUNK_SIZE)
7676
.remainder()

src/hnsw.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ impl<'a, D: Distance, const M: usize, const M0: usize> HnswBuilder<'a, D, M, M0>
173173

174174
level_groups.into_iter().try_for_each(|grp| {
175175
grp.into_par_iter().try_for_each(|&(item_id, lvl)| {
176-
if cancel_index.fetch_add(1, Relaxed) % CANCELLATION_PROBING == 0 && (self.cancel)()
176+
if cancel_index.fetch_add(1, Relaxed).is_multiple_of(CANCELLATION_PROBING) && (self.cancel)()
177177
{
178178
Err(Error::BuildCancelled)
179179
} else {
@@ -362,7 +362,7 @@ impl<'a, D: Distance, const M: usize, const M0: usize> HnswBuilder<'a, D, M, M0>
362362
let cancel_index = AtomicUsize::new(0);
363363

364364
links_in_db.into_par_iter().try_for_each(|result| {
365-
if cancel_index.fetch_add(1, Ordering::Relaxed) % CANCELLATION_PROBING == 0
365+
if cancel_index.fetch_add(1, Ordering::Relaxed).is_multiple_of(CANCELLATION_PROBING)
366366
&& (self.cancel)()
367367
{
368368
return Err(Error::BuildCancelled);

src/spaces/simple.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ pub fn dot_product_non_optimized(u: &UnalignedVector<f32>, v: &UnalignedVector<f
102102
///
103103
/// 2. Then we need to do the sum of the results:
104104
/// 2.1 First we must do the sum of the operation on the `Word`s
105-
/// /!\ We must be careful here because `1 - 0` actually translates to `1 - 1 = 0`.
106-
/// `word.count_ones() - word.count_zeroes()` should do it:
105+
/// /!\ We must be careful here because `1 - 0` actually translates to `1 - 1 = 0`.
106+
/// `word.count_ones() - word.count_zeroes()` should do it:
107107
/// ```text
108108
/// 00 => -2
109109
/// 01 => 0

src/unaligned_vector/binary.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ unsafe fn from_slice_neon(slice: &[f32]) -> Vec<u8> {
101101
// The size of the returned vector must be a multiple of a word
102102
let remaining = slice.len() % PACKED_WORD_BYTES;
103103
let mut len = iterations;
104-
if len % PACKED_WORD_BYTES != 0 {
104+
if !len.is_multiple_of(PACKED_WORD_BYTES) {
105105
len += PACKED_WORD_BYTES - len % PACKED_WORD_BYTES;
106106
} else if remaining != 0 {
107107
// if we generated a valid number of Word but we're missing a few bits

src/unaligned_vector/binary_quantized.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ unsafe fn from_slice_neon(slice: &[f32]) -> Vec<u8> {
9898
// The size of the returned vector must be a multiple of a word
9999
let remaining = slice.len() % QUANTIZED_WORD_BYTES;
100100
let mut len = iterations;
101-
if len % QUANTIZED_WORD_BYTES != 0 {
101+
if !len.is_multiple_of(QUANTIZED_WORD_BYTES) {
102102
len += QUANTIZED_WORD_BYTES - len % QUANTIZED_WORD_BYTES;
103103
} else if remaining != 0 {
104104
// if we generated a valid number of Word but we're missing a few bits

0 commit comments

Comments
 (0)