Skip to content

Commit 0e8f518

Browse files
authored
perf(array): avoid double bounds check in ArrayIterator (risingwavelabs#8685)
Signed-off-by: TennyZhuang <[email protected]>
1 parent 16c9708 commit 0e8f518

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/common/src/array/iterator.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ impl<'a, A: Array> Iterator for ArrayIterator<'a, A> {
3434
if self.pos >= self.data.len() {
3535
None
3636
} else {
37-
let item = self.data.value_at(self.pos);
37+
// SAFETY: bounds check is done by `self.pos < self.data.len()`.
38+
let item = unsafe { self.data.value_at_unchecked(self.pos) };
3839
self.pos += 1;
3940
Some(item)
4041
}

0 commit comments

Comments
 (0)