mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-12-20 08:01:46 +03:00
Return earlier if original_length < 2 and remove unnecessary call to saturating_sub()
This commit is contained in:
parent
9895f12ed2
commit
4892272a08
@ -81,13 +81,16 @@ impl Signature {
|
||||
panic!("unsupported signature version");
|
||||
}
|
||||
|
||||
let original_length = u32::from_le_bytes(self.0[1..5].try_into().unwrap());
|
||||
let original_length = u32::from_le_bytes(self.0[1..5].try_into().expect("invalid length"));
|
||||
if original_length < 2 {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
let other = other.as_ref();
|
||||
let other_string: String = other.chars().filter(|&x| !char::is_whitespace(x)).collect();
|
||||
let other = other_string.as_bytes();
|
||||
|
||||
if original_length < 2 || other.len() < 2 {
|
||||
if other.len() < 2 {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
@ -100,7 +103,7 @@ impl Signature {
|
||||
let right = right >> SHIFT;
|
||||
let index = ((left as usize) << BITS) | (right as usize);
|
||||
if self_buckets[index] > 0 {
|
||||
self_buckets[index] = self_buckets[index].saturating_sub(1);
|
||||
self_buckets[index] = self_buckets[index] - 1;
|
||||
matching_bigrams += 1;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user