You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kvrocks.apache.org by ti...@apache.org on 2022/06/21 09:29:19 UTC
[incubator-kvrocks] branch unstable updated: Optimize happy path for constructing Status (#643)
This is an automated email from the ASF dual-hosted git repository.
tison pushed a commit to branch unstable
in repository https://gitbox.apache.org/repos/asf/incubator-kvrocks.git
The following commit(s) were added to refs/heads/unstable by this push:
new d2a9701 Optimize happy path for constructing Status (#643)
d2a9701 is described below
commit d2a970177c9d8852c57a8ab0c6581533d41b343b
Author: Twice <tw...@gmail.com>
AuthorDate: Tue Jun 21 17:29:13 2022 +0800
Optimize happy path for constructing Status (#643)
---
src/status.h | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/src/status.h b/src/status.h
index 1878bbf..8727f1c 100644
--- a/src/status.h
+++ b/src/status.h
@@ -57,13 +57,18 @@ class Status {
NetSendErr,
};
- Status() : Status(cOK, "ok") {}
- explicit Status(Code code, std::string msg = "") : code_(code), msg_(std::move(msg)) {}
+ Status() : Status(cOK) {}
+ explicit Status(Code code, std::string msg = {}) : code_(code), msg_(std::move(msg)) {}
bool IsOK() { return code_ == cOK; }
bool IsNotFound() { return code_ == NotFound; }
bool IsImorting() { return code_ == SlotImport; }
- std::string Msg() { return msg_; }
- static Status OK() { return Status(cOK, "ok"); }
+ std::string Msg() {
+ if (IsOK()) {
+ return "ok";
+ }
+ return msg_;
+ }
+ static Status OK() { return {}; }
private:
Code code_;