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

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


The following commit(s) were added to refs/heads/main by this push:
     new a2548a79a1 GH-35124: [C++] Avoid unnecessary copy when outputting join 
result (#35114)
a2548a79a1 is described below

commit a2548a79a191c280966d869c7778643fd64fdcd6
Author: ruoxi <[email protected]>
AuthorDate: Tue Apr 18 14:17:31 2023 +0800

    GH-35124: [C++] Avoid unnecessary copy when outputting join result (#35114)
    
    
    
    ### Rationale for this change
    
    Seems this 
https://github.com/apache/arrow/blob/913c34506000fd77444ea7b7f24dcb6402003d6b/cpp/src/arrow/acero/swiss_join_internal.h#L571
 is an unnecessary copy when outputting join result batch. According to Sasha 
K.:
    
    > I _think_ the compiler will automatically emit the move because it sees 
we’re copying from an object that’ll never be used again [1], but adding the 
std::move would be good just to remove any ambiguity.
    
    ### What changes are included in this PR?
    
    Adding `std::move()` to disambiguate/eliminate the unnecessary copy.
    
    ### Are these changes tested?
    
    No. This change is possibly undetectable, and the existing tests should 
cover it well.
    
    ### Are there any user-facing changes?
    
    No.
    
    * Closes: #35124
    
    Authored-by: zanmato1984 <[email protected]>
    Signed-off-by: Weston Pace <[email protected]>
---
 cpp/src/arrow/acero/swiss_join_internal.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cpp/src/arrow/acero/swiss_join_internal.h 
b/cpp/src/arrow/acero/swiss_join_internal.h
index 17bacaf144..cd12b34a0c 100644
--- a/cpp/src/arrow/acero/swiss_join_internal.h
+++ b/cpp/src/arrow/acero/swiss_join_internal.h
@@ -568,7 +568,7 @@ class JoinResultMaterialize {
       if (num_rows_appended < num_rows_to_append) {
         ExecBatch batch;
         ARROW_RETURN_NOT_OK(Flush(&batch));
-        ARROW_RETURN_NOT_OK(output_batch_fn(batch));
+        ARROW_RETURN_NOT_OK(output_batch_fn(std::move(batch)));
         num_rows_to_append -= num_rows_appended;
         offset += num_rows_appended;
       } else {

Reply via email to