From 86741d645da005b2ed17e30aebdef7b6e02633de Mon Sep 17 00:00:00 2001 From: Benjamin Kietzman Date: Mon, 4 Nov 2024 11:53:42 -0600 Subject: [PATCH] Pack Struct::State a little with reordered is_constant --- cpp/src/arrow/status.cc | 4 ++-- cpp/src/arrow/status.h | 2 +- cpp/src/arrow/status_internal.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cpp/src/arrow/status.cc b/cpp/src/arrow/status.cc index de2955de4619e..81f5f88e0f0d1 100644 --- a/cpp/src/arrow/status.cc +++ b/cpp/src/arrow/status.cc @@ -28,7 +28,7 @@ Status::Status(StatusCode code, const std::string& msg) Status::Status(StatusCode code, std::string msg, std::shared_ptr detail) { ARROW_CHECK_NE(code, StatusCode::OK) << "Cannot construct ok status with message"; - state_ = new State{code, std::move(msg), std::move(detail)}; + state_ = new State{code, /*is_constant=*/false, std::move(msg), std::move(detail)}; } void Status::CopyFrom(const Status& s) { @@ -165,7 +165,7 @@ void Status::AddContextLine(const char* filename, int line, const char* expr) { ss << "\n" << filename << ":" << line << " " << expr; if (state_->is_constant) { // We can't add context lines to a StatusConstant's state, so copy it now - state_ = new State{code(), message(), detail()}; + state_ = new State{code(), /*is_constant=*/false, message(), detail()}; } const_cast(state_)->msg += ss.str(); } diff --git a/cpp/src/arrow/status.h b/cpp/src/arrow/status.h index 45d61a63c4f57..a52a3600e434d 100644 --- a/cpp/src/arrow/status.h +++ b/cpp/src/arrow/status.h @@ -369,9 +369,9 @@ class ARROW_EXPORT [[nodiscard]] Status : public util::EqualityComparable detail; - bool is_constant = false; }; // OK status has a `NULL` state_. Otherwise, `state_` points to // a `State` structure containing the error code and message(s) diff --git a/cpp/src/arrow/status_internal.h b/cpp/src/arrow/status_internal.h index 77474e389533f..80e6cd2cd610f 100644 --- a/cpp/src/arrow/status_internal.h +++ b/cpp/src/arrow/status_internal.h @@ -26,7 +26,7 @@ class StatusConstant { public: StatusConstant(StatusCode code, std::string msg, std::shared_ptr detail = nullptr) - : state_{code, std::move(msg), std::move(detail), /*is_constant=*/true} { + : state_{code, /*is_constant=*/true, std::move(msg), std::move(detail)} { ARROW_CHECK_NE(code, StatusCode::OK) << "StatusConstant is not intended for use with OK status codes"; }