diff options
Diffstat (limited to 'absl')
-rw-r--r-- | absl/strings/cord.cc | 2 | ||||
-rw-r--r-- | absl/strings/cord.h | 3 |
2 files changed, 4 insertions, 1 deletions
diff --git a/absl/strings/cord.cc b/absl/strings/cord.cc index 2b61bdfc..ea84e446 100644 --- a/absl/strings/cord.cc +++ b/absl/strings/cord.cc @@ -425,8 +425,8 @@ Cord& Cord::operator=(absl::string_view src) { // we keep it here to make diffs easier. void Cord::InlineRep::AppendArray(absl::string_view src, MethodIdentifier method) { - MaybeRemoveEmptyCrcNode(); if (src.empty()) return; // memcpy(_, nullptr, 0) is undefined. + MaybeRemoveEmptyCrcNode(); size_t appended = 0; CordRep* rep = tree(); diff --git a/absl/strings/cord.h b/absl/strings/cord.h index 2583aa8a..5aebd567 100644 --- a/absl/strings/cord.h +++ b/absl/strings/cord.h @@ -75,6 +75,7 @@ #include "absl/base/internal/per_thread_tls.h" #include "absl/base/macros.h" #include "absl/base/nullability.h" +#include "absl/base/optimization.h" #include "absl/base/port.h" #include "absl/container/inlined_vector.h" #include "absl/crc/internal/crc_cord_state.h" @@ -1388,6 +1389,7 @@ inline void Cord::Prepend(absl::string_view src) { inline void Cord::Append(CordBuffer buffer) { if (ABSL_PREDICT_FALSE(buffer.length() == 0)) return; + contents_.MaybeRemoveEmptyCrcNode(); absl::string_view short_value; if (CordRep* rep = buffer.ConsumeValue(short_value)) { contents_.AppendTree(rep, CordzUpdateTracker::kAppendCordBuffer); @@ -1398,6 +1400,7 @@ inline void Cord::Append(CordBuffer buffer) { inline void Cord::Prepend(CordBuffer buffer) { if (ABSL_PREDICT_FALSE(buffer.length() == 0)) return; + contents_.MaybeRemoveEmptyCrcNode(); absl::string_view short_value; if (CordRep* rep = buffer.ConsumeValue(short_value)) { contents_.PrependTree(rep, CordzUpdateTracker::kPrependCordBuffer); |