Skip to content

Commit 68dd24e

Browse files
authored
Merge pull request #71 from ClickHouse/avoid-static-vars-in-status.h
apacheGH-45099: [C++] Avoid static const variable in the status.h
2 parents 210f686 + 6ba3c94 commit 68dd24e

2 files changed

Lines changed: 12 additions & 8 deletions

File tree

cpp/src/arrow/status.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,16 @@ std::string Status::ToStringWithoutContextLines() const {
138138
return message;
139139
}
140140

141+
const std::string& Status::message() const {
142+
static const std::string no_message = "";
143+
return ok() ? no_message : state_->msg;
144+
}
145+
146+
const std::shared_ptr<StatusDetail>& Status::detail() const {
147+
static std::shared_ptr<StatusDetail> no_detail = NULLPTR;
148+
return state_ ? state_->detail : no_detail;
149+
}
150+
141151
void Status::Abort() const { Abort(std::string()); }
142152

143153
void Status::Abort(const std::string& message) const {

cpp/src/arrow/status.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -329,16 +329,10 @@ class ARROW_EXPORT [[nodiscard]] Status : public util::EqualityComparable<Status
329329
constexpr StatusCode code() const { return ok() ? StatusCode::OK : state_->code; }
330330

331331
/// \brief Return the specific error message attached to this status.
332-
const std::string& message() const {
333-
static const std::string no_message = "";
334-
return ok() ? no_message : state_->msg;
335-
}
332+
const std::string& message() const;
336333

337334
/// \brief Return the status detail attached to this message.
338-
const std::shared_ptr<StatusDetail>& detail() const {
339-
static std::shared_ptr<StatusDetail> no_detail = NULLPTR;
340-
return state_ ? state_->detail : no_detail;
341-
}
335+
const std::shared_ptr<StatusDetail>& detail() const;
342336

343337
/// \brief Return a new Status copying the existing status, but
344338
/// updating with the existing detail.

0 commit comments

Comments
 (0)