This is an automated email from the ASF dual-hosted git repository.

tustvold pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git


The following commit(s) were added to refs/heads/master by this push:
     new 474dc14b2 Improve performance of set_bits by using copy_from_slice 
instead of setting individual bytes (#2077)
474dc14b2 is described below

commit 474dc14b2e80062c18b98a8667d4d878afb8249a
Author: Jörn Horstmann <[email protected]>
AuthorDate: Fri Jul 15 17:06:41 2022 +0200

    Improve performance of set_bits by using copy_from_slice instead of setting 
individual bytes (#2077)
---
 arrow/src/util/bit_mask.rs | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/arrow/src/util/bit_mask.rs b/arrow/src/util/bit_mask.rs
index 501a46173..da542a2bb 100644
--- a/arrow/src/util/bit_mask.rs
+++ b/arrow/src/util/bit_mask.rs
@@ -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

Reply via email to