Replace all assert! with debug_assert!

This results in a ~6% reduction in instruction count.
This commit is contained in:
Amanieu d'Antras
2022-01-11 03:54:08 +00:00
parent a27f93f01e
commit 74928b83fa
13 changed files with 82 additions and 73 deletions

View File

@@ -93,7 +93,7 @@ impl AdaptiveMap {
};
if needs_expand {
assert!(small_mode_idx.is_none());
debug_assert!(small_mode_idx.is_none());
self.expand();
}
@@ -111,7 +111,7 @@ impl AdaptiveMap {
}
// Otherwise, the key must not be present; add a new
// entry.
assert!(*len < SMALL_ELEMS as u32);
debug_assert!(*len < SMALL_ELEMS as u32);
let idx = *len;
*len += 1;
keys[idx as usize] = key;
@@ -344,11 +344,11 @@ mod test {
let mut checksum = 0;
for bit in vec.iter() {
assert!(bit % 17 == 0);
debug_assert!(bit % 17 == 0);
checksum += bit;
}
assert_eq!(sum, checksum);
debug_assert_eq!(sum, checksum);
}
#[test]
@@ -362,6 +362,6 @@ mod test {
// should still be in small mode.
vec.set(64 * 5, false);
vec.set(64 * 100, true);
assert!(vec.is_small());
debug_assert!(vec.is_small());
}
}