Skip to content

Commit

Permalink
GH-44581: [C++] Minor: ArrayData ctor can assign null_count directly (#…
Browse files Browse the repository at this point in the history
…44582)

### Rationale for this change

See https://godbolt.org/z/37reoKTfK

The `ArrayData` ctor can assign `null_count` directly, rather than `SetNullCount`.

### What changes are included in this PR?

Change `null_count` assigned directly

### Are these changes tested?

Covered by existing

### Are there any user-facing changes?

No

* GitHub Issue: #44581

Authored-by: mwish <[email protected]>
Signed-off-by: mwish <[email protected]>
  • Loading branch information
mapleFU authored Oct 31, 2024
1 parent 5b68eca commit 3917b60
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
14 changes: 6 additions & 8 deletions cpp/src/arrow/array/data.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,25 +150,23 @@ struct ARROW_EXPORT ArrayData {
ArrayData(ArrayData&& other) noexcept
: type(std::move(other.type)),
length(other.length),
null_count(other.null_count.load()),
offset(other.offset),
buffers(std::move(other.buffers)),
child_data(std::move(other.child_data)),
dictionary(std::move(other.dictionary)),
statistics(std::move(other.statistics)) {
SetNullCount(other.null_count);
}
statistics(std::move(other.statistics)) {}

// Copy constructor
ArrayData(const ArrayData& other) noexcept
: type(other.type),
length(other.length),
null_count(other.null_count.load()),
offset(other.offset),
buffers(other.buffers),
child_data(other.child_data),
dictionary(other.dictionary),
statistics(other.statistics) {
SetNullCount(other.null_count);
}
statistics(other.statistics) {}

// Move assignment
ArrayData& operator=(ArrayData&& other) {
Expand Down Expand Up @@ -324,7 +322,7 @@ struct ARROW_EXPORT ArrayData {

/// \brief Return true if the validity bitmap may have 0's in it, or if the
/// child arrays (in the case of types without a validity bitmap) may have
/// nulls, or if the dictionary of dictionay array may have nulls.
/// nulls, or if the dictionary of dictionary array may have nulls.
///
/// This is not a drop-in replacement for MayHaveNulls, as historically
/// MayHaveNulls() has been used to check for the presence of a validity
Expand Down Expand Up @@ -639,7 +637,7 @@ struct ARROW_EXPORT ArraySpan {
bool HasVariadicBuffers() const;

private:
ARROW_FRIEND_EXPORT friend bool internal::IsNullRunEndEncoded(const ArrayData& span,
ARROW_FRIEND_EXPORT friend bool internal::IsNullRunEndEncoded(const ArrayData& data,
int64_t i);

bool IsNullSparseUnion(int64_t i) const;
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/extension_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class ARROW_EXPORT ExtensionType : public DataType {

protected:
explicit ExtensionType(std::shared_ptr<DataType> storage_type)
: DataType(Type::EXTENSION), storage_type_(storage_type) {}
: DataType(Type::EXTENSION), storage_type_(std::move(storage_type)) {}

std::shared_ptr<DataType> storage_type_;
};
Expand Down

0 comments on commit 3917b60

Please sign in to comment.