Copilot commented on code in PR #49660:
URL: https://github.com/apache/arrow/pull/49660#discussion_r3070146720


##########
cpp/src/gandiva/gdv_function_stubs.cc:
##########
@@ -269,7 +269,15 @@ const char* gdv_fn_base64_decode_utf8(int64_t context, 
const char* in, int32_t i
     return "";
   }
   // use arrow method to decode base64 string
-  std::string decoded_str = arrow::util::base64_decode(std::string_view(in, 
in_len));
+  auto result = arrow::util::base64_decode(std::string_view(in, in_len));
+  if (!result.ok()) {
+    gdv_fn_context_set_error_msg(context, result.status().message().c_str());
+    *out_len = 0;
+    return "";
+  }
+
+  std::string decoded_str = *result;

Review Comment:
   This copies the decoded string out of `Result<std::string>` (`operator*` 
returns a reference). Since you already checked `ok()`, consider moving the 
value out of `result` (e.g., via `std::move(result).ValueOrDie()`) to avoid an 
extra allocation/copy, especially for large inputs.



-- 
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