felipecrv commented on code in PR #44493:
URL: https://github.com/apache/arrow/pull/44493#discussion_r1809617145


##########
cpp/src/arrow/status.h:
##########
@@ -363,17 +357,25 @@ class ARROW_EXPORT [[nodiscard]] Status : public 
util::EqualityComparable<Status
   void AddContextLine(const char* filename, int line, const char* expr);
 #endif
 
+  // Construct a Status which is not destroyed and is cheap to copy.
+  static Status MakeStatic(StatusCode code, std::string msg,
+                           std::shared_ptr<StatusDetail> detail);
  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() {

Review Comment:
   Put `noexcept` here as well for consistency with `~Status() noexcept`.



##########
cpp/src/arrow/status.h:
##########
@@ -363,17 +357,25 @@ class ARROW_EXPORT [[nodiscard]] Status : public 
util::EqualityComparable<Status
   void AddContextLine(const char* filename, int line, const char* expr);
 #endif
 
+  // Construct a Status which is not destroyed and is cheap to copy.
+  static Status MakeStatic(StatusCode code, std::string msg,
+                           std::shared_ptr<StatusDetail> detail);
  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() {
+    // ARROW-2400: On certain compilers, splitting off the slow path improves
+    // performance significantly.
+    if (ARROW_PREDICT_TRUE(state_ == NULL)) return;
+    if (ARROW_PREDICT_FALSE(state_->is_static)) return;

Review Comment:
   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;
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to