Skip to content

Commit f8d9572

Browse files
authored
Change BooleanBuffer::append_packed_range to use apply_bitwise_binary_op (#8812)
# Which issue does this PR close? - related to #8561 # Rationale for this change We added an optimized packed implementation in the following PR: - #8619 Let's use it to make append_packed_range faster # What changes are included in this PR? - Use `apply_bitwise_binary_op` # Are these changes tested? Functionally by CI I will also run benchmarks for this PR # Are there any user-facing changes? Faster peformance
1 parent 5a1a13a commit f8d9572

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

arrow-buffer/src/builder/boolean.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

18-
use crate::{BooleanBuffer, Buffer, MutableBuffer, bit_mask, bit_util};
18+
use crate::bit_util::apply_bitwise_binary_op;
19+
use crate::{BooleanBuffer, Buffer, MutableBuffer, bit_util};
1920
use std::ops::Range;
2021

2122
/// Builder for [`BooleanBuffer`]
@@ -218,13 +219,16 @@ impl BooleanBufferBuilder {
218219
pub fn append_packed_range(&mut self, range: Range<usize>, to_set: &[u8]) {
219220
let offset_write = self.len;
220221
let len = range.end - range.start;
222+
// allocate new bits as 0
221223
self.advance(len);
222-
bit_mask::set_bits(
224+
// copy bits from to_set into self.buffer a word at a time
225+
apply_bitwise_binary_op(
223226
self.buffer.as_slice_mut(),
224-
to_set,
225227
offset_write,
228+
to_set,
226229
range.start,
227230
len,
231+
|_a, b| b, // copy bits from to_set
228232
);
229233
}
230234

0 commit comments

Comments
 (0)