Commit 0e72e54f by Abseil Team Committed by Copybara-Service

Add noexcept to move assignment operator and swap function

This resolves a couple of Clang Tidy performance warnings.

PiperOrigin-RevId: 609394317
Change-Id: Ibebc7e3f7121355b8660284e18c110bb9171d61c
parent 3afe4fed
...@@ -452,7 +452,7 @@ class ABSL_ATTRIBUTE_TRIVIAL_ABI Status final { ...@@ -452,7 +452,7 @@ class ABSL_ATTRIBUTE_TRIVIAL_ABI Status final {
// The moved-from state is valid but unspecified. // The moved-from state is valid but unspecified.
Status(Status&&) noexcept; Status(Status&&) noexcept;
Status& operator=(Status&&); Status& operator=(Status&&) noexcept;
~Status(); ~Status();
...@@ -539,7 +539,7 @@ class ABSL_ATTRIBUTE_TRIVIAL_ABI Status final { ...@@ -539,7 +539,7 @@ class ABSL_ATTRIBUTE_TRIVIAL_ABI Status final {
// swap() // swap()
// //
// Swap the contents of one status with another. // Swap the contents of one status with another.
friend void swap(Status& a, Status& b); friend void swap(Status& a, Status& b) noexcept;
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// Payload Management APIs // Payload Management APIs
...@@ -789,7 +789,7 @@ inline Status::Status(Status&& x) noexcept : Status(x.rep_) { ...@@ -789,7 +789,7 @@ inline Status::Status(Status&& x) noexcept : Status(x.rep_) {
x.rep_ = MovedFromRep(); x.rep_ = MovedFromRep();
} }
inline Status& Status::operator=(Status&& x) { inline Status& Status::operator=(Status&& x) noexcept {
uintptr_t old_rep = rep_; uintptr_t old_rep = rep_;
if (x.rep_ != old_rep) { if (x.rep_ != old_rep) {
rep_ = x.rep_; rep_ = x.rep_;
...@@ -852,7 +852,7 @@ inline void Status::IgnoreError() const { ...@@ -852,7 +852,7 @@ inline void Status::IgnoreError() const {
// no-op // no-op
} }
inline void swap(absl::Status& a, absl::Status& b) { inline void swap(absl::Status& a, absl::Status& b) noexcept {
using std::swap; using std::swap;
swap(a.rep_, b.rep_); swap(a.rep_, b.rep_);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment