refactor(allocator): remove pointless debug_assert!s#21728
Conversation
Merging this PR will not alter performance
Comparing Footnotes
|
There was a problem hiding this comment.
Pull request overview
This PR refactors oxc_allocator arena utilities by removing redundant debug_assert!(divisor > 0) checks where debug_assert!(divisor.is_power_of_two()) already guarantees non-zero, reducing debug-build code size and minor overhead.
Changes:
- Remove redundant
debug_assert!(divisor > 0)fromround_up_to,round_down_to,round_mut_ptr_down_to, andround_mut_ptr_up_to_unchecked.
Merge activity
|
`usize::is_power_of_two` already returns `false` for `0`, so this is pointless duplication: ```rust debug_assert!(n > 0); debug_assert!(n.is_power_of_two()); ``` Remove the first `debug_assert!` in these cases, to reduce code size and improve perf in debug builds.
4aac05b to
a717a55
Compare

usize::is_power_of_twoalready returnsfalsefor0, so this is pointless duplication:Remove the first
debug_assert!in these cases, to reduce code size and improve perf in debug builds.