diff options
author | Andreas Grois <andi@grois.info> | 2022-10-19 21:28:36 +0200 |
---|---|---|
committer | Andreas Grois <andi@grois.info> | 2022-10-19 21:28:36 +0200 |
commit | bc9bd89c17dc41d9b1434866ac2d522070f46597 (patch) | |
tree | 1c9a57c6be182ac457c4d91f37e69122effb3c31 /src | |
parent | 308e4ec700b9047836876b4581d24bfe7b1a7e2d (diff) |
Make some asserts debug_asserts. Add more benches.
Now that work on performance has started, accurate readings are
important.
Diffstat (limited to 'src')
-rw-r--r-- | src/passwordmaker/base_conversion/remainders_impl.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/passwordmaker/base_conversion/remainders_impl.rs b/src/passwordmaker/base_conversion/remainders_impl.rs index 7de2189..7bc6c0e 100644 --- a/src/passwordmaker/base_conversion/remainders_impl.rs +++ b/src/passwordmaker/base_conversion/remainders_impl.rs @@ -9,20 +9,20 @@ impl<const N : usize> Division<usize> for [u32;N] { type UsizeAndFour = u128; #[cfg(not(target_pointer_width = "64"))] type UsizeAndFour = u64; - assert!((UsizeAndFour::MAX >> 32) as u128 >= usize::MAX as u128); + debug_assert!((UsizeAndFour::MAX >> 32) as u128 >= usize::MAX as u128); //uses mutation, because why not? self is owned after all :D let divisor : UsizeAndFour = *divisor as UsizeAndFour; let remainder = self.iter_mut().fold(0 as UsizeAndFour,|carry, current| { - assert_eq!(carry, carry & (usize::MAX as UsizeAndFour)); //carry has to be lower than divisor, and divisor is usize. + debug_assert_eq!(carry, carry & (usize::MAX as UsizeAndFour)); //carry has to be lower than divisor, and divisor is usize. let carry_shifted = carry << 32; let dividend = (carry_shifted) + (*current as UsizeAndFour); let ratio = dividend / divisor; - assert_eq!(ratio, ratio & 0xffff_ffff); //this is fine. The first digit after re-adding the carry is alwys zero. + debug_assert_eq!(ratio, ratio & 0xffff_ffff); //this is fine. The first digit after re-adding the carry is alwys zero. *current = (ratio) as u32; dividend - (*current as UsizeAndFour) * divisor }); - assert_eq!(remainder, remainder & (usize::MAX as UsizeAndFour)); + debug_assert_eq!(remainder, remainder & (usize::MAX as UsizeAndFour)); let remainder = remainder as usize; DivisionResult{ result: self, |