diff options
author | Abseil Team <absl-team@google.com> | 2021-04-09 08:51:11 -0700 |
---|---|---|
committer | Dino Radaković <dinor@google.com> | 2021-04-13 16:33:48 +0000 |
commit | b97a1ecda869ca8754d467a56c50275cebfeb328 (patch) | |
tree | cfb45ecb84e81c1e1fb54937538fccd8ed63401d | |
parent | 3b4a16abad2c2ddc494371cc39a2946e36d35d11 (diff) |
Export of internal Abseil changes
--
9bd9d083a21d1436816dc842a80d4339aa49a24b by Abseil Team <absl-team@google.com>:
Inline Status::NewRep, pass `message` via string_view in StatusRep ctor
PiperOrigin-RevId: 367641069
--
9cebe53e8f1717f82394501fd9f4bc70d2051b33 by Benjamin Barenblat <bbaren@google.com>:
Fix typo in CordRepRing error message
PiperOrigin-RevId: 367481280
GitOrigin-RevId: 9bd9d083a21d1436816dc842a80d4339aa49a24b
Change-Id: Ie2c51bf6f46abed5c2317ceee30bd2bb59502f8e
-rw-r--r-- | absl/status/internal/status_internal.h | 4 | ||||
-rw-r--r-- | absl/status/status.cc | 22 | ||||
-rw-r--r-- | absl/strings/internal/cord_rep_ring.cc | 2 |
3 files changed, 10 insertions, 18 deletions
diff --git a/absl/status/internal/status_internal.h b/absl/status/internal/status_internal.h index 99a2d96..ccafd70 100644 --- a/absl/status/internal/status_internal.h +++ b/absl/status/internal/status_internal.h @@ -47,11 +47,11 @@ using Payloads = absl::InlinedVector<Payload, 1>; // Reference-counted representation of Status data. struct StatusRep { - StatusRep(absl::StatusCode code, std::string message, + StatusRep(absl::StatusCode code, absl::string_view message, std::unique_ptr<status_internal::Payloads> payloads) : ref(int32_t{1}), code(code), - message(std::move(message)), + message(message), payloads(std::move(payloads)) {} std::atomic<int32_t> ref; diff --git a/absl/status/status.cc b/absl/status/status.cc index 51a0d26..5a5cd5c 100644 --- a/absl/status/status.cc +++ b/absl/status/status.cc @@ -207,19 +207,10 @@ void Status::UnrefNonInlined(uintptr_t rep) { } } -uintptr_t Status::NewRep( - absl::StatusCode code, absl::string_view msg, - std::unique_ptr<status_internal::Payloads> payloads) { - status_internal::StatusRep* rep = new status_internal::StatusRep( - code, std::string(msg.data(), msg.size()), - std::move(payloads)); - return PointerToRep(rep); -} - Status::Status(absl::StatusCode code, absl::string_view msg) : rep_(CodeToInlinedRep(code)) { if (code != absl::StatusCode::kOk && !msg.empty()) { - rep_ = NewRep(code, msg, nullptr); + rep_ = PointerToRep(new status_internal::StatusRep(code, msg, nullptr)); } } @@ -238,9 +229,9 @@ absl::StatusCode Status::code() const { void Status::PrepareToModify() { ABSL_RAW_CHECK(!ok(), "PrepareToModify shouldn't be called on OK status."); if (IsInlined(rep_)) { - rep_ = - NewRep(static_cast<absl::StatusCode>(raw_code()), absl::string_view(), - nullptr); + rep_ = PointerToRep(new status_internal::StatusRep( + static_cast<absl::StatusCode>(raw_code()), absl::string_view(), + nullptr)); return; } @@ -251,8 +242,9 @@ void Status::PrepareToModify() { if (rep->payloads) { payloads = absl::make_unique<status_internal::Payloads>(*rep->payloads); } - rep_ = NewRep(rep->code, message(), - std::move(payloads)); + status_internal::StatusRep* const new_rep = new status_internal::StatusRep( + rep->code, message(), std::move(payloads)); + rep_ = PointerToRep(new_rep); UnrefNonInlined(rep_i); } } diff --git a/absl/strings/internal/cord_rep_ring.cc b/absl/strings/internal/cord_rep_ring.cc index cb95b19..0995129 100644 --- a/absl/strings/internal/cord_rep_ring.cc +++ b/absl/strings/internal/cord_rep_ring.cc @@ -301,7 +301,7 @@ bool CordRepRing::IsValid(std::ostream& output) const { if (offset >= child->length || entry_length > child->length - offset) { output << "entry[" << head << "] has offset " << offset << " and entry length " << entry_length - << " which are outside of the childs length of " << child->length; + << " which are outside of the child's length of " << child->length; return false; } |