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
This commit is contained in:
Abseil Team
2023-06-09 07:46:15 -07:00
committed by Copybara-Service
parent 66eae02ea7
commit 87ce390379

View File

@@ -146,7 +146,13 @@ void AppendPieces(std::string* dest,
void StrAppend(std::string* dest, const AlphaNum& 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) {