File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -157,13 +157,15 @@ impl<T: ByteArrayType> GenericByteBuilder<T> {
157157 // Shifting all the offsets
158158 let shift: T :: Offset = self . next_offset ( ) - offsets[ 0 ] ;
159159
160- // Creating intermediate offsets instead of pushing each offset is faster
161- // (even if we make MutableBuffer to avoid updating length on each push
162- // and reserve the necessary capacity, it's still slower)
163- let mut intermediate = Vec :: with_capacity ( offsets. len ( ) - 1 ) ;
160+ use num:: Zero ;
164161
165- for & offset in & offsets[ 1 ..] {
166- intermediate. push ( offset + shift)
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;
167169 }
168170
169171 self . offsets_builder . extend_from_slice ( & intermediate) ;
You can’t perform that action at this time.
0 commit comments