felipecrv commented on code in PR #41021:
URL: https://github.com/apache/arrow/pull/41021#discussion_r1553653479


##########
cpp/src/arrow/array/builder_nested.h:
##########
@@ -181,14 +181,13 @@ class ARROW_EXPORT VarLengthListLikeBuilder : public 
ArrayBuilder {
     if constexpr (is_list_view(TYPE::type_id)) {
       sizes = array.GetValues<offset_type>(2);
     }
+    const bool has_validity = array.buffers[0].data != NULLPTR;
     const bool all_valid = !array.MayHaveLogicalNulls();
-    const uint8_t* validity = array.HasValidityBitmap() ? 
array.buffers[0].data : NULLPTR;
     ARROW_RETURN_NOT_OK(Reserve(length));
     for (int64_t row = offset; row < offset + length; row++) {
-      const bool is_valid =
-          all_valid || (validity && bit_util::GetBit(validity, array.offset + 
row)) ||
-          array.IsValid(row);
       int64_t size = 0;
+      ARROW_COMPILER_ASSUME(has_validity == (array.buffers[0].data != 
NULLPTR));

Review Comment:
   No, I explained here 
https://github.com/apache/arrow/pull/41021#discussion_r1553637741
   
   This allows the compiler to assume `array.buffers[0].data != NULLPTR` is the 
same as `has_validity` so when `IsValid` is inlined, it replaces that 
memory-value check with a local-variable check (most likely stored in a 
register).
   
   Assumption are things that (1) I prove to be be definitely true, and that 
(2) the compiler can trust as true and generate better code.
   
   You can take a look on the links I posted in `macros.h` to understand 
assumptions better.



-- 
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: [email protected]

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

Reply via email to