Skip to content

Commit fd5a012

Browse files
committed
change to iterator that will also use SIMD without intermediate buffer
1 parent 2ee80db commit fd5a012

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

arrow-array/src/builder/generic_bytes_builder.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -157,18 +157,8 @@ impl<T: ByteArrayType> GenericByteBuilder<T> {
157157
// Shifting all the offsets
158158
let shift: T::Offset = self.next_offset() - offsets[0];
159159

160-
use num::Zero;
161-
162-
// Creating intermediate offsets instead of pushing each offsets is faster.
163-
//
164-
// Not using Vec::with_capacity and push as it will not use SIMD for some reason.
165-
let mut intermediate = vec![T::Offset::zero(); offsets.len() - 1];
166-
167-
for (index, &offset) in offsets[1..].iter().enumerate() {
168-
intermediate[index] = offset + shift;
169-
}
170-
171-
self.offsets_builder.extend_from_slice(&intermediate);
160+
self.offsets_builder
161+
.extend(offsets[1..].iter().map(|&offset| offset + shift));
172162
}
173163

174164
// Append underlying values, starting from the first offset and ending at the last offset

0 commit comments

Comments
 (0)