Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions cpp/src/arrow/status.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ Status::Status(StatusCode code, std::string msg, std::shared_ptr<StatusDetail> d

void Status::CopyFrom(const Status& s) {
if (ARROW_PREDICT_FALSE(state_ != NULL)) {
if (!state_->is_constant) {
DeleteState();
}
DeleteState();
}
if (s.state_ == nullptr) {
state_ = nullptr;
Expand Down
17 changes: 9 additions & 8 deletions cpp/src/arrow/status.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,12 @@ class ARROW_EXPORT [[nodiscard]] Status : public util::EqualityComparable<Status
public:
// Create a success status.
constexpr Status() noexcept : state_(NULLPTR) {}
~Status() noexcept {

// GH-47774: force-inline the Status destructor's hot path
// and keep it as lean as possible.
ARROW_FORCE_INLINE ~Status() noexcept {
Comment thread
pitrou marked this conversation as resolved.
if (ARROW_PREDICT_FALSE(state_ != NULL)) {
if (!state_->is_constant) {
DeleteState();
}
DeleteState();
}
}

Expand Down Expand Up @@ -409,7 +410,9 @@ class ARROW_EXPORT [[nodiscard]] Status : public util::EqualityComparable<Status
void DeleteState() noexcept {
// ARROW-2400: On certain compilers, splitting off the slow path improves
// performance significantly.
delete state_;
if (!state_->is_constant) {
delete state_;
}
}
void CopyFrom(const Status& s);
inline void MoveFrom(Status& s);
Expand All @@ -419,9 +422,7 @@ class ARROW_EXPORT [[nodiscard]] Status : public util::EqualityComparable<Status

void Status::MoveFrom(Status& s) {
if (ARROW_PREDICT_FALSE(state_ != NULL)) {
if (!state_->is_constant) {
DeleteState();
}
DeleteState();
}
state_ = s.state_;
s.state_ = NULLPTR;
Expand Down
Loading