Skip to content

Commit

Permalink
perf(entity): entity::Raw::range can safely assume non-zero output
Browse files Browse the repository at this point in the history
  • Loading branch information
SOF3 authored Oct 19, 2023
1 parent eff4ecc commit 2ab9b8d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/entity/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,10 @@ macro_rules! impl_raw {
type Range = impl Iterator<Item = Self>;
fn range(range: ops::Range<Self>) -> Self::Range {
(range.start.get()..range.end.get()).map(|v| {
<$base>::new(v)
.expect("zero does not appear between two non-zero unsigned integers")
// Safety: v >= range.start.get(), which is guaranteed to be non-zero.
// Unsafe is necessary here because this function is called during chunk iteration,
// and this branch may break vectorization.
unsafe { <$base>::new_unchecked(v) }
})
}
}
Expand Down

0 comments on commit 2ab9b8d

Please sign in to comment.