From 0e8f518637fcd4d63b2f8a707430588b5e15c041 Mon Sep 17 00:00:00 2001 From: TennyZhuang Date: Tue, 21 Mar 2023 16:59:02 +0800 Subject: [PATCH] perf(array): avoid double bounds check in ArrayIterator (#8685) Signed-off-by: TennyZhuang --- src/common/src/array/iterator.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/common/src/array/iterator.rs b/src/common/src/array/iterator.rs index 5072903489a4b..c0d4e2361053a 100644 --- a/src/common/src/array/iterator.rs +++ b/src/common/src/array/iterator.rs @@ -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) }