From f780db102d9d4b4cbcb20ce0a1e85acc5e9cb93f Mon Sep 17 00:00:00 2001 From: yaojun <940334249@qq.com> Date: Fri, 20 Feb 2026 11:38:29 +0800 Subject: [PATCH 1/2] Fix(C++): use std::move to avoid unnecessary copies --- cpp/src/parquet/arrow/reader.cc | 2 +- cpp/src/parquet/metadata.cc | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cpp/src/parquet/arrow/reader.cc b/cpp/src/parquet/arrow/reader.cc index a77323d29fad..11c4c408da98 100644 --- a/cpp/src/parquet/arrow/reader.cc +++ b/cpp/src/parquet/arrow/reader.cc @@ -976,7 +976,7 @@ Status GetReader(const SchemaField& field, const std::shared_ptr& arrow_f if (!schema_child_type.Equals(reader_child_type)) { child_field = child_field->WithType(child_reader->field()->type()); } - child_fields.push_back(child_field); + child_fields.push_back(std::move(child_field)); child_readers.emplace_back(std::move(child_reader)); } if (child_fields.empty()) { diff --git a/cpp/src/parquet/metadata.cc b/cpp/src/parquet/metadata.cc index 505ace275b11..7e9b358ce067 100644 --- a/cpp/src/parquet/metadata.cc +++ b/cpp/src/parquet/metadata.cc @@ -177,9 +177,9 @@ std::shared_ptr FromThriftKeyValueMetadata(const Metadata& sou std::vector values; keys.reserve(source.key_value_metadata.size()); values.reserve(source.key_value_metadata.size()); - for (const auto& it : source.key_value_metadata) { - keys.push_back(it.key); - values.push_back(it.value); + for (auto& it : source.key_value_metadata) { + keys.push_back(std::move(it.key)); + values.push_back(std::move(it.value)); } metadata = std::make_shared(std::move(keys), std::move(values)); } From 9f1d97e3a7ea8923e8f58b6fccdf12cd40548715 Mon Sep 17 00:00:00 2001 From: Jason Date: Thu, 14 May 2026 12:21:18 +0800 Subject: [PATCH 2/2] fix: restore changes in metadata.cc Signed-off-by: Jason --- cpp/src/parquet/metadata.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cpp/src/parquet/metadata.cc b/cpp/src/parquet/metadata.cc index 7e9b358ce067..505ace275b11 100644 --- a/cpp/src/parquet/metadata.cc +++ b/cpp/src/parquet/metadata.cc @@ -177,9 +177,9 @@ std::shared_ptr FromThriftKeyValueMetadata(const Metadata& sou std::vector values; keys.reserve(source.key_value_metadata.size()); values.reserve(source.key_value_metadata.size()); - for (auto& it : source.key_value_metadata) { - keys.push_back(std::move(it.key)); - values.push_back(std::move(it.value)); + for (const auto& it : source.key_value_metadata) { + keys.push_back(it.key); + values.push_back(it.value); } metadata = std::make_shared(std::move(keys), std::move(values)); }