-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GH-44491: [C++] Static Status draft #44493
base: main
Are you sure you want to change the base?
Conversation
|
if (ARROW_PREDICT_TRUE(state_ == NULL)) return; | ||
if (ARROW_PREDICT_FALSE(state_->is_static)) return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably better to have a single condition here to make it obvious that the rest of the function is the cold code:
if (ARROW_PREDICT_TRUE(state_ == NULL || state_->is_static)) return;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that this is more obvious for human readers, but I think the priority here is to make it obvious to the compiler that the hottest condition is state_ == NULL
, independent of any other consideration
private: | ||
struct State { | ||
StatusCode code; | ||
std::string msg; | ||
std::shared_ptr<StatusDetail> detail; | ||
bool is_static = false; | ||
}; | ||
// OK status has a `NULL` state_. Otherwise, `state_` points to | ||
// a `State` structure containing the error code and message(s) | ||
State* state_; | ||
|
||
void DeleteState() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put noexcept
here as well for consistency with ~Status() noexcept
.
Rationale for this change
It'd be convenient to construct placeholder error Status cheaply.
What changes are included in this PR?
Added
bool Status::State::is_static
which causes copies to be shallow and skips destruction.Are these changes tested?
Not yet. Also, the main consideration is probably benchmarks to make sure hot paths don't get much slower.
Are there any user-facing changes?
I don't think we want this API to be public