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


##########
cpp/src/arrow/status_internal.h:
##########
@@ -0,0 +1,43 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include "arrow/status.h"
+#include "arrow/util/logging.h"
+
+namespace arrow::internal {
+
+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} {
+    ARROW_CHECK_NE(code, StatusCode::OK) << "Cannot construct ok status 
constant";

Review Comment:
   Well, we could, but it's counter to the reason of `StatusConstant` existing. 
Message should be `StatusConstant is not meant to be used to construct an OK 
status"`



##########
cpp/src/arrow/status.cc:
##########
@@ -26,18 +28,19 @@ 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;
-  state_->code = code;
-  state_->msg = std::move(msg);
-  if (detail != nullptr) {
-    state_->detail = std::move(detail);
-  }
+  state_ = new State{code, std::move(msg), std::move(detail)};
 }
 
+// We would prefer that this destructor *not* be inlined, since the vast 
majority of
+// Statuses are OK and so inlining would superflously increase binary size.
+Status::State::~State() = default;

Review Comment:
   My guess is that it's better to have this inlined, but avoid inlining 
`DeleteState` (which is effectively what the previous implementation was 
achieving with
   
   ```cpp
       if (ARROW_PREDICT_FALSE(state_ != NULL)) {
         DeleteState();
       }
   ```



-- 
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