Commits


Benjamin Kietzman authored and GitHub committed 29e8ea01104
GH-44491: [C++] StatusConstant- cheaply copied const Status (#44493) ### Rationale for this change It'd be convenient to construct placeholder error Status cheaply. ### What changes are included in this PR? A constant error Status can now be constructed wrapped in a function like ```c++ Status UninitializedResult() { static StatusConstant uninitialized_result{StatusCode::UnknownError, "Uninitialized Result<T>"}; return uninitialized_result; } ``` Copying the constant status is relatively cheap (no heap interaction), so it's suitable for use as a placeholder error status. Added `bool Status::State::is_constant` which causes copies to be shallow and skips destruction. Also `Status::state_` is a const pointer now; this helps to ensure that it is obvious when we mutate state_ (as in AddContextLine). ### Are these changes tested? Minimal unit test added. The main consideration is probably benchmarks to make sure hot paths don't get much slower. ### Are there any user-facing changes? This API is not currently public; no user-facing changes. * GitHub Issue: #44491 Lead-authored-by: Benjamin Kietzman <bengilgit@gmail.com> Co-authored-by: Antoine Pitrou <antoine@python.org> Signed-off-by: Antoine Pitrou <antoine@python.org>