diff --git a/cpp/src/arrow/array/array_dict.cc b/cpp/src/arrow/array/array_dict.cc index 7fd76a1dae81b..55e086af30bc2 100644 --- a/cpp/src/arrow/array/array_dict.cc +++ b/cpp/src/arrow/array/array_dict.cc @@ -349,7 +349,7 @@ class DictionaryUnifierImpl : public DictionaryUnifier { using MemoTableType = typename DictTraits::MemoTableType; DictionaryUnifierImpl(MemoryPool* pool, std::shared_ptr value_type) - : pool_(pool), value_type_(value_type), memo_table_(pool) {} + : pool_(pool), value_type_(std::move(value_type)), memo_table_(pool) {} Status Unify(const Array& dictionary, std::shared_ptr* out) override { if (dictionary.null_count() > 0) { @@ -432,7 +432,7 @@ struct MakeUnifier { std::unique_ptr result; MakeUnifier(MemoryPool* pool, std::shared_ptr value_type) - : pool(pool), value_type(value_type) {} + : pool(pool), value_type(std::move(value_type)) {} template enable_if_no_memoize Visit(const T&) { diff --git a/cpp/src/arrow/array/array_nested.cc b/cpp/src/arrow/array/array_nested.cc index 47c0fd35829a1..bb469df1ad6b4 100644 --- a/cpp/src/arrow/array/array_nested.cc +++ b/cpp/src/arrow/array/array_nested.cc @@ -542,7 +542,7 @@ Result> ListArray::FromArrays( const Array& offsets, const Array& values, MemoryPool* pool, std::shared_ptr null_bitmap, int64_t null_count) { return ListArrayFromArrays(std::make_shared(values.type()), offsets, - values, pool, null_bitmap, null_count); + values, pool, std::move(null_bitmap), null_count); } Result> ListArray::FromListView(const ListViewArray& source, @@ -563,7 +563,7 @@ Result> ListArray::FromArrays( return Status::TypeError("Mismatching list value type"); } return ListArrayFromArrays(std::move(type), offsets, values, pool, - null_bitmap, null_count); + std::move(null_bitmap), null_count); } Result> ListArray::Flatten(MemoryPool* memory_pool) const { @@ -599,8 +599,8 @@ Result> LargeListArray::FromArrays( const Array& offsets, const Array& values, MemoryPool* pool, std::shared_ptr null_bitmap, int64_t null_count) { return ListArrayFromArrays( - std::make_shared(values.type()), offsets, values, pool, null_bitmap, - null_count); + std::make_shared(values.type()), offsets, values, pool, + std::move(null_bitmap), null_count); } Result> LargeListArray::FromListView( @@ -622,7 +622,7 @@ Result> LargeListArray::FromArrays( return Status::TypeError("Mismatching list value type"); } return ListArrayFromArrays(std::move(type), offsets, values, pool, - null_bitmap, null_count); + std::move(null_bitmap), null_count); } Result> LargeListArray::Flatten(MemoryPool* memory_pool) const { @@ -662,7 +662,7 @@ Result> ListViewArray::FromArrays( std::shared_ptr null_bitmap, int64_t null_count) { return ListViewArrayFromArrays( std::make_shared(values.type()), offsets, sizes, values, pool, - null_bitmap, null_count); + std::move(null_bitmap), null_count); } Result> ListViewArray::FromArrays( @@ -677,7 +677,7 @@ Result> ListViewArray::FromArrays( return Status::TypeError("Mismatching list-view value type"); } return ListViewArrayFromArrays(std::move(type), offsets, sizes, values, - pool, null_bitmap, null_count); + pool, std::move(null_bitmap), null_count); } Result> ListViewArray::FromList(const ListArray& source, @@ -722,7 +722,7 @@ LargeListViewArray::LargeListViewArray(std::shared_ptr type, int64_t l std::shared_ptr null_bitmap, int64_t null_count, int64_t offset) { LargeListViewArray::SetData(ArrayData::Make( - type, length, + std::move(type), length, {std::move(null_bitmap), std::move(value_offsets), std::move(value_sizes)}, /*child_data=*/{values->data()}, null_count, offset)); } @@ -737,7 +737,7 @@ Result> LargeListViewArray::FromArrays( std::shared_ptr null_bitmap, int64_t null_count) { return ListViewArrayFromArrays( std::make_shared(values.type()), offsets, sizes, values, pool, - null_bitmap, null_count); + std::move(null_bitmap), null_count); } Result> LargeListViewArray::FromArrays( @@ -752,7 +752,7 @@ Result> LargeListViewArray::FromArrays( return Status::TypeError("Mismatching large list-view value type"); } return ListViewArrayFromArrays( - std::move(type), offsets, sizes, values, pool, null_bitmap, null_count); + std::move(type), offsets, sizes, values, pool, std::move(null_bitmap), null_count); } Result> LargeListViewArray::Flatten( @@ -854,8 +854,9 @@ Result> MapArray::FromArraysInternal( null_count = kUnknownNullCount; } buffers[1] = typed_offsets.values(); - return std::make_shared(type, offsets->length() - 1, std::move(buffers), keys, - items, /*null_count=*/null_count, offsets->offset()); + return std::make_shared(std::move(type), offsets->length() - 1, + std::move(buffers), keys, items, + /*null_count=*/null_count, offsets->offset()); } Result> MapArray::FromArrays(const std::shared_ptr& offsets, @@ -971,8 +972,8 @@ Result> FixedSizeListArray::FromArrays( int64_t length = values->length() / list_size; auto list_type = std::make_shared(values->type(), list_size); - return std::make_shared(list_type, length, values, null_bitmap, - null_count); + return std::make_shared(list_type, length, values, + std::move(null_bitmap), null_count); } Result> FixedSizeListArray::FromArrays( @@ -992,8 +993,8 @@ Result> FixedSizeListArray::FromArrays( } int64_t length = values->length() / list_type.list_size(); - return std::make_shared(type, length, values, null_bitmap, - null_count); + return std::make_shared(std::move(type), length, values, + std::move(null_bitmap), null_count); } Result> FixedSizeListArray::Flatten( @@ -1015,7 +1016,7 @@ StructArray::StructArray(const std::shared_ptr& type, int64_t length, std::shared_ptr null_bitmap, int64_t null_count, int64_t offset) { ARROW_CHECK_EQ(type->id(), Type::STRUCT); - SetData(ArrayData::Make(type, length, {null_bitmap}, null_count, offset)); + SetData(ArrayData::Make(type, length, {std::move(null_bitmap)}, null_count, offset)); for (const auto& child : children) { data_->child_data.push_back(child->data()); } @@ -1048,7 +1049,7 @@ Result> StructArray::Make( null_count = 0; } return std::make_shared(struct_(fields), length - offset, children, - null_bitmap, null_count, offset); + std::move(null_bitmap), null_count, offset); } Result> StructArray::Make( @@ -1085,8 +1086,8 @@ const std::shared_ptr& StructArray::field(int i) const { } else { field_data = data_->child_data[i]; } - std::shared_ptr result = MakeArray(field_data); - std::atomic_store(&boxed_fields_[i], result); + result = MakeArray(field_data); + std::atomic_store(&boxed_fields_[i], std::move(result)); return boxed_fields_[i]; } return boxed_fields_[i];