tustvold commented on code in PR #2740: URL: https://github.com/apache/arrow-rs/pull/2740#discussion_r973608091
########## arrow/src/compute/kernels/arity.rs: ########## @@ -298,36 +297,41 @@ where let len = a.len(); if a.null_count() == 0 && b.null_count() == 0 { - let values = a.values().iter().zip(b.values()).map(|(l, r)| op(*l, *r)); - let buffer = unsafe { Buffer::try_from_trusted_len_iter(values) }?; - // JUSTIFICATION - // Benefit - // ~75% speedup - // Soundness - // `values` is an iterator with a known size from a PrimitiveArray - return Ok(unsafe { build_primitive_array(len, buffer, 0, None) }); + let mut buffer = BufferBuilder::<O::Native>::new(len); + buffer.append_n_zeroed(len); Review Comment: It would be faster to reserve the correct capacity and use push_unchecked. Avoids zero allocating. As written I suspect this is a performance regression as this if block is effectively identical to the one below now -- 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. To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org