Skip to content

Commit

Permalink
Improve performance of set_bits by using copy_from_slice instead of s…
Browse files Browse the repository at this point in the history
…etting individual bytes (#2077)
  • Loading branch information
jhorstmann committed Jul 15, 2022
1 parent 86543a4 commit 474dc14
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions arrow/src/util/bit_mask.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,9 @@ pub fn set_bits(
let chunks = BitChunks::new(data, offset_read + bits_to_align, len - bits_to_align);
chunks.iter().for_each(|chunk| {
null_count += chunk.count_zeros();
chunk.to_le_bytes().iter().for_each(|b| {
write_data[write_byte_index] = *b;
write_byte_index += 1;
})
write_data[write_byte_index..write_byte_index + 8]
.copy_from_slice(&chunk.to_le_bytes());
write_byte_index += 8;
});

// Set individual bits both to align write_data to a byte offset and the remainder bits not covered by the bit chunk iterator
Expand Down

0 comments on commit 474dc14

Please sign in to comment.