Skip to content

Commit

Permalink
Pack Struct::State a little with reordered is_constant
Browse files Browse the repository at this point in the history
  • Loading branch information
bkietz committed Nov 8, 2024
1 parent 0ca52d1 commit d13d04e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions cpp/src/arrow/status.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Status::Status(StatusCode code, const std::string& msg)

Status::Status(StatusCode code, std::string msg, std::shared_ptr<StatusDetail> 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) {
Expand Down Expand Up @@ -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*>(state_)->msg += ss.str();
}
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/status.h
Original file line number Diff line number Diff line change
Expand Up @@ -369,9 +369,9 @@ class ARROW_EXPORT [[nodiscard]] Status : public util::EqualityComparable<Status
private:
struct State {
StatusCode code;
bool is_constant;
std::string msg;
std::shared_ptr<StatusDetail> 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)
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/status_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class StatusConstant {
public:
StatusConstant(StatusCode code, std::string msg,
std::shared_ptr<StatusDetail> 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";
}
Expand Down

0 comments on commit d13d04e

Please sign in to comment.