Skip to content

Commit bfd2bd4

Browse files
committed
refactor: use collect_bool in BitBuffer From<Vec<bool>> impl
Signed-off-by: Joe Isaacs <[email protected]>
1 parent 4552c10 commit bfd2bd4

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

vortex-buffer/src/bit/buf_mut.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -541,14 +541,8 @@ impl Not for BitBufferMut {
541541

542542
impl From<&[bool]> for BitBufferMut {
543543
fn from(value: &[bool]) -> Self {
544-
let mut buf = BitBufferMut::new_unset(value.len());
545-
for (i, &v) in value.iter().enumerate() {
546-
if v {
547-
// SAFETY: i is in bounds
548-
unsafe { buf.set_unchecked(i) }
549-
}
550-
}
551-
buf
544+
// Use the optimized collect_bool to pack 64 booleans at a time
545+
BitBuffer::collect_bool(value.len(), |i| value[i]).into_mut()
552546
}
553547
}
554548

0 commit comments

Comments
 (0)