Skip to content

Commit

Permalink
apacheGH-35124: [C++] Avoid unnecessary copy when outputting join res…
Browse files Browse the repository at this point in the history
…ult (apache#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: apache#35124

Authored-by: zanmato1984 <zanmato1984@gmail.com>
Signed-off-by: Weston Pace <weston.pace@gmail.com>
  • Loading branch information
zanmato1984 authored and rtpsw committed May 16, 2023
1 parent 53ee1e2 commit 202bdea
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion cpp/src/arrow/acero/swiss_join_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 202bdea

Please sign in to comment.