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

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


The following commit(s) were added to refs/heads/main by this push:
     new ba0b374261 perf: skip checking if there is null if already 
materialized (#10756)
ba0b374261 is described below

commit ba0b3742613b198659b950cee18192681ab83b1f
Author: Raz Luvaton <[email protected]>
AuthorDate: Thu Aug 20 01:12:02 2026 +0300

    perf: skip checking if there is null if already materialized (#10756)
    
    # Which issue does this PR close?
    
    N/A
    
    # Rationale for this change
    
    We can avoid the slice iterations if no need to materialize which can
    improve perf for large slices
    
    # What changes are included in this PR?
    lift condition
    
    # Are these changes tested?
    Existing tests
    
    # Are there any user-facing changes?
    No
---
 arrow-buffer/src/builder/null.rs | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arrow-buffer/src/builder/null.rs b/arrow-buffer/src/builder/null.rs
index 5040208474..b1b5511010 100644
--- a/arrow-buffer/src/builder/null.rs
+++ b/arrow-buffer/src/builder/null.rs
@@ -192,8 +192,9 @@ impl NullBufferBuilder {
     /// Appends a boolean slice into the builder
     /// to indicate the validations of these items.
     pub fn append_slice(&mut self, slice: &[bool]) {
-        if slice.iter().any(|v| !v) {
-            self.materialize_if_needed()
+        // First check if not already materialized before checking if there 
are any nulls
+        if self.bitmap_builder.is_none() && slice.iter().any(|v| !v) {
+            self.materialize()
         }
         if let Some(buf) = self.bitmap_builder.as_mut() {
             buf.append_slice(slice)

Reply via email to