summaryrefslogtreecommitdiff
path: root/absl/strings/cord.cc
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2021-05-06 20:08:01 -0700
committerGravatar Andy Getz <durandal@google.com>2021-05-07 13:51:04 -0400
commit079cf662544a14bd1cfaae6d6512645541ba10fb (patch)
tree99d164c0162508aa69ace6879d9a36f89e145065 /absl/strings/cord.cc
parent70b29fe5a5c1752158830eabc9aa273718b477af (diff)
Export of internal Abseil changes
-- 51e9291d9bc385082b4061fe760b236ba59c79c3 by Abseil Team <absl-team@google.com>: Cast to uint64_t using braces instead of parentheses. PiperOrigin-RevId: 372475909 -- 939fc409855da2639dcaf2d1d4971ca0e0568d03 by Martijn Vels <mvels@google.com>: Expand # flat nodes into size detailed counters. PiperOrigin-RevId: 372474608 -- 54b158c99b32f8a14821ce74fed0f9f836525ce7 by Martijn Vels <mvels@google.com>: Make copies of sampled cords sampled as well This applies to the following methods: - Cord(const Cord&) - operator=(const Cord&) - Subcord(...) PiperOrigin-RevId: 372468160 -- 876c2581ce008871464e8b471efbb967d150f83b by Andy Getzendanner <durandal@google.com>: Document the type of an ABSL_FLAGS.OnUpdate() callback. PiperOrigin-RevId: 372406390 GitOrigin-RevId: 51e9291d9bc385082b4061fe760b236ba59c79c3 Change-Id: Ifb75122cae56b66c28128aee90a63bbb28d93817
Diffstat (limited to 'absl/strings/cord.cc')
-rw-r--r--absl/strings/cord.cc21
1 files changed, 11 insertions, 10 deletions
diff --git a/absl/strings/cord.cc b/absl/strings/cord.cc
index 1c2ff9f2..238532f9 100644
--- a/absl/strings/cord.cc
+++ b/absl/strings/cord.cc
@@ -531,18 +531,19 @@ void Cord::InlineRep::AssignSlow(const Cord::InlineRep& src) {
assert(&src != this);
assert(is_tree() || src.is_tree());
auto constexpr method = CordzUpdateTracker::kAssignCord;
- if (CordRep* tree = this->tree()) {
- CordzUpdateScope scope(data_.cordz_info(), method);
- CordRep::Unref(tree);
- if (CordRep* src_tree = src.tree()) {
- SetTree(CordRep::Ref(src_tree), scope);
- } else {
- scope.SetCordRep(nullptr);
- data_ = src.data_;
- }
+ if (ABSL_PREDICT_TRUE(!is_tree())) {
+ EmplaceTree(CordRep::Ref(src.as_tree()), src.data_, method);
+ return;
+ }
+ CordRep* tree = as_tree();
+ if (CordRep* src_tree = src.tree()) {
+ data_.set_tree(CordRep::Ref(src_tree));
+ CordzInfo::MaybeTrackCord(data_, src.data_, method);
} else {
- EmplaceTree(CordRep::Ref(src.as_tree()), method);
+ CordzInfo::MaybeUntrackCord(data_.cordz_info());
+ data_ = src.data_;
}
+ CordRep::Unref(tree);
}
void Cord::InlineRep::UnrefTree() {