Skip to content

Commit

Permalink
perf(array): avoid double bounds check in ArrayIterator (risingwavela…
Browse files Browse the repository at this point in the history
…bs#8685)

Signed-off-by: TennyZhuang <[email protected]>
  • Loading branch information
TennyZhuang authored Mar 21, 2023
1 parent 16c9708 commit 0e8f518
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/common/src/array/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ impl<'a, A: Array> Iterator for ArrayIterator<'a, A> {
if self.pos >= self.data.len() {
None
} else {
let item = self.data.value_at(self.pos);
// SAFETY: bounds check is done by `self.pos < self.data.len()`.
let item = unsafe { self.data.value_at_unchecked(self.pos) };
self.pos += 1;
Some(item)
}
Expand Down

0 comments on commit 0e8f518

Please sign in to comment.