From d67c41cb24e4219250bdb0fb469c0cd92f3d06ac Mon Sep 17 00:00:00 2001 From: Connor Tsui Date: Tue, 18 Aug 2026 14:11:19 -0400 Subject: [PATCH] Deduplicate BitBuffer set-index visitors Signed-off-by: Connor Tsui --- vortex-buffer/src/bit/buf.rs | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/vortex-buffer/src/bit/buf.rs b/vortex-buffer/src/bit/buf.rs index 1da0b037f2a..ddfca546d30 100644 --- a/vortex-buffer/src/bit/buf.rs +++ b/vortex-buffer/src/bit/buf.rs @@ -1,6 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: Copyright the Vortex contributors +use std::convert::Infallible; use std::fmt::Display; use std::fmt::Formatter; use std::fmt::Result as FmtResult; @@ -462,21 +463,10 @@ impl BitBuffer { /// (whose per-`next` iterator state does not inline as well). #[inline] pub fn for_each_set_index(&self, mut f: F) { - let mut base = 0usize; - for word in self.chunks().iter_padded() { - if word == u64::MAX { - for k in 0..64 { - f(base + k); - } - } else { - let mut w = word; - while w != 0 { - f(base + w.trailing_zeros() as usize); - w &= w - 1; - } - } - base += 64; - } + let Ok(()) = self.try_for_each_set_index(|index| { + f(index); + Ok::<_, Infallible>(()) + }); } /// Fallible variant of [`for_each_set_index`](Self::for_each_set_index).