diff --git a/cpp/src/arrow/compute/cast.cc b/cpp/src/arrow/compute/cast.cc index 4a8bca3f1d2..13d3debf463 100644 --- a/cpp/src/arrow/compute/cast.cc +++ b/cpp/src/arrow/compute/cast.cc @@ -178,7 +178,7 @@ Result CastFunction::DispatchExact( } } - if (candidate_kernels.size() == 0) { + if (candidate_kernels.empty()) { return Status::NotImplemented("Unsupported cast from ", types[0].type->ToString(), " to ", ToTypeName(out_type_id_), " using function ", this->name()); diff --git a/cpp/src/arrow/compute/exec.cc b/cpp/src/arrow/compute/exec.cc index db86a75c53f..231d37f6b3b 100644 --- a/cpp/src/arrow/compute/exec.cc +++ b/cpp/src/arrow/compute/exec.cc @@ -1311,7 +1311,7 @@ int64_t InferBatchLength(const std::vector& values, bool* all_same) { } } - if (are_all_scalar && values.size() > 0) { + if (are_all_scalar && !values.empty()) { length = 1; } else if (length < 0) { length = 0; diff --git a/cpp/src/arrow/compute/kernels/scalar_nested.cc b/cpp/src/arrow/compute/kernels/scalar_nested.cc index c5d9624bada..30937a33def 100644 --- a/cpp/src/arrow/compute/kernels/scalar_nested.cc +++ b/cpp/src/arrow/compute/kernels/scalar_nested.cc @@ -1146,7 +1146,7 @@ Result MakeStructResolve(KernelContext* ctx, auto nullable = OptionsWrapper::Get(ctx).field_nullability; auto metadata = OptionsWrapper::Get(ctx).field_metadata; - if (names.size() == 0) { + if (names.empty()) { names.resize(types.size()); nullable.resize(types.size(), true); metadata.resize(types.size(), nullptr); diff --git a/cpp/src/arrow/compute/kernels/vector_replace.cc b/cpp/src/arrow/compute/kernels/vector_replace.cc index 9b42e5d6cbb..a27638a7bcd 100644 --- a/cpp/src/arrow/compute/kernels/vector_replace.cc +++ b/cpp/src/arrow/compute/kernels/vector_replace.cc @@ -773,7 +773,7 @@ struct FillNullBackwardChunked { ArrayData* array_with_current = values.chunk(/*first_chunk=*/chunks_length - 1)->data().get(); int64_t last_valid_value_offset = -1; - auto chunks = values.chunks(); + const auto& chunks = values.chunks(); for (int i = chunks_length - 1; i >= 0; --i) { const auto& chunk = chunks[i]; if (is_fixed_width(out->type()->id())) { diff --git a/cpp/src/arrow/compute/kernels/vector_select_k.cc b/cpp/src/arrow/compute/kernels/vector_select_k.cc index 7a63c76f4ef..8efb2e806c4 100644 --- a/cpp/src/arrow/compute/kernels/vector_select_k.cc +++ b/cpp/src/arrow/compute/kernels/vector_select_k.cc @@ -481,12 +481,12 @@ class RecordBatchSelector { first_remaining_sort_key.order, output.non_null_like_range); } - if (output.nan_range.size() > 0) { + if (!output.nan_range.empty()) { // We have the last sort_key, can just copy over the null values std::copy(p.nan_begin(), p.nan_begin() + output.nan_range.size(), output.nan_begin()); } - if (output.null_range.size() > 0) { + if (!output.null_range.empty()) { // We have the last sort_key, can just copy over the null values std::copy(p.null_begin(), p.null_begin() + output.null_range.size(), output.null_begin()); @@ -499,11 +499,11 @@ class RecordBatchSelector { HeapSortNonNullsToOutput(p.non_null_like_range, cmp, output.non_null_like_range); } - if (output.nan_range.size() > 0) { + if (!output.nan_range.empty()) { ARROW_RETURN_NOT_OK(selector_->DoSelectKForKey(start_sort_key_index_ + 1, p.nan_range, output.nan_range)); } - if (output.null_range.size() > 0) { + if (!output.null_range.empty()) { ARROW_RETURN_NOT_OK(selector_->DoSelectKForKey( start_sort_key_index_ + 1, p.null_range, output.null_range)); } diff --git a/cpp/src/arrow/pretty_print.cc b/cpp/src/arrow/pretty_print.cc index 72344992859..f61c71ecc00 100644 --- a/cpp/src/arrow/pretty_print.cc +++ b/cpp/src/arrow/pretty_print.cc @@ -264,7 +264,7 @@ class ArrayPrinter : public PrettyPrinter { template enable_if_t::value || is_list_view_type::value, Status> WriteDataValues(const ArrayType& array) { - const auto values = array.values(); + const auto& values = array.values(); const auto child_options = ChildOptions(); ArrayPrinter values_printer(child_options, sink_); diff --git a/cpp/src/arrow/tensor.cc b/cpp/src/arrow/tensor.cc index 8b3137d66a3..292899e3fec 100644 --- a/cpp/src/arrow/tensor.cc +++ b/cpp/src/arrow/tensor.cc @@ -526,7 +526,7 @@ Tensor::Tensor(const std::shared_ptr& type, const std::shared_ptr& dim_names) : type_(type), data_(data), shape_(shape), strides_(strides), dim_names_(dim_names) { ARROW_CHECK(is_tensor_supported(type->id())); - if (shape.size() > 0 && strides.size() == 0) { + if (!shape.empty() && strides.empty()) { ARROW_CHECK_OK(internal::ComputeRowMajorStrides( checked_cast(*type_), shape, &strides_)); } @@ -542,7 +542,7 @@ Tensor::Tensor(const std::shared_ptr& type, const std::shared_ptr(dim_names_.size())); diff --git a/cpp/src/parquet/metadata.cc b/cpp/src/parquet/metadata.cc index 2bc871a8c86..7d0565b0f42 100644 --- a/cpp/src/parquet/metadata.cc +++ b/cpp/src/parquet/metadata.cc @@ -2107,7 +2107,7 @@ class FileMetaDataBuilder::FileMetaDataBuilderImpl { total_rows += row_group.num_rows; } metadata_->__set_num_rows(total_rows); - metadata_->__set_row_groups(row_groups_); + metadata_->row_groups = std::move(row_groups_); if (key_value_metadata) { ToThriftKeyValueMetadata(*key_value_metadata, metadata_.get()); @@ -2144,7 +2144,7 @@ class FileMetaDataBuilder::FileMetaDataBuilderImpl { ToThrift(file_encryption_properties->algorithm())); const std::string& footer_signing_key_metadata = file_encryption_properties->footer_key_metadata(); - if (footer_signing_key_metadata.size() > 0) { + if (!footer_signing_key_metadata.empty()) { metadata_->__set_footer_signing_key_metadata(footer_signing_key_metadata); } } @@ -2172,7 +2172,7 @@ class FileMetaDataBuilder::FileMetaDataBuilderImpl { crypto_metadata_->__set_encryption_algorithm( ToThrift(file_encryption_properties->algorithm())); - std::string key_metadata = file_encryption_properties->footer_key_metadata(); + const std::string& key_metadata = file_encryption_properties->footer_key_metadata(); if (!key_metadata.empty()) { crypto_metadata_->__set_key_metadata(key_metadata);