Dandandan commented on a change in pull request #8803:
URL: https://github.com/apache/arrow/pull/8803#discussion_r532415763



##########
File path: rust/arrow/src/compute/kernels/take.rs
##########
@@ -214,19 +215,20 @@ where
 
     let null_count = array.null_count();
 
-    // This iteration is implemented with a while loop, rather than a
-    // map()/collect(), since the while loop performs better in the benchmarks.
-    let mut new_values: Vec<T::Native> = Vec::with_capacity(data_len);
+    let mut buffer = MutableBuffer::new(data_len * 
std::mem::size_of::<T::Native>());
+    buffer.resize(data_len * std::mem::size_of::<T::Native>());
+    let data = buffer.typed_data_mut();
+
     let nulls;
 
     if null_count == 0 {
         // Take indices without null checking
-        for i in 0..data_len {
+        for (i, elem) in data.iter_mut().enumerate() {

Review comment:
       Yes, it also leads to faster code in some cases as indexing only in 
limited cases gets rid of bounds checking.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to