diff options
author | Abseil Team <absl-team@google.com> | 2024-01-18 09:10:55 -0800 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2024-01-18 09:11:43 -0800 |
commit | 49ff696cda14c4825a99ced4ff6b6bbe20dd38ce (patch) | |
tree | 12b936197ab47a163cff22e32705c720ba42eafb /absl/crc/internal | |
parent | fe16a5e72d69d8319e53fb8b9c2e9d2b4e43a207 (diff) |
Migrate empty CrcCordState to absl::NoDestructor.
Note that this only changes how we allocate the empty state, and reference countings of `empty` stay the same.
PiperOrigin-RevId: 599526339
Change-Id: I2c6aaf875c144c947e17fe8f69692b1195b55dd7
Diffstat (limited to 'absl/crc/internal')
-rw-r--r-- | absl/crc/internal/crc_cord_state.cc | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/absl/crc/internal/crc_cord_state.cc b/absl/crc/internal/crc_cord_state.cc index 28d04dc4..303a5559 100644 --- a/absl/crc/internal/crc_cord_state.cc +++ b/absl/crc/internal/crc_cord_state.cc @@ -17,6 +17,7 @@ #include <cassert> #include "absl/base/config.h" +#include "absl/base/no_destructor.h" #include "absl/numeric/bits.h" namespace absl { @@ -24,14 +25,14 @@ ABSL_NAMESPACE_BEGIN namespace crc_internal { CrcCordState::RefcountedRep* CrcCordState::RefSharedEmptyRep() { - static CrcCordState::RefcountedRep* empty = new CrcCordState::RefcountedRep; + static absl::NoDestructor<CrcCordState::RefcountedRep> empty; assert(empty->count.load(std::memory_order_relaxed) >= 1); assert(empty->rep.removed_prefix.length == 0); assert(empty->rep.prefix_crc.empty()); - Ref(empty); - return empty; + Ref(empty.get()); + return empty.get(); } CrcCordState::CrcCordState() : refcounted_rep_(new RefcountedRep) {} |