Commit 87ce3903 by Abseil Team Committed by Copybara-Service

The previous code was using `memmove` under the hood (`string::append`).

This patch makes it use `memcpy` for performance and consistency with other overloads.

PiperOrigin-RevId: 539079130
Change-Id: I5aea9dd9b8a1ce708c787df7d6c9a75ae419c484
parent 66eae02e
...@@ -146,7 +146,13 @@ void AppendPieces(std::string* dest, ...@@ -146,7 +146,13 @@ void AppendPieces(std::string* dest,
void StrAppend(std::string* dest, const AlphaNum& a) { void StrAppend(std::string* dest, const AlphaNum& a) {
ASSERT_NO_OVERLAP(*dest, a); ASSERT_NO_OVERLAP(*dest, a);
dest->append(a.data(), a.size()); std::string::size_type old_size = dest->size();
strings_internal::STLStringResizeUninitializedAmortized(dest,
old_size + a.size());
char* const begin = &(*dest)[0];
char* out = begin + old_size;
out = Append(out, a);
assert(out == begin + dest->size());
} }
void StrAppend(std::string* dest, const AlphaNum& a, const AlphaNum& b) { void StrAppend(std::string* dest, const AlphaNum& a, const AlphaNum& b) {
......
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