From 25a85cdd6f55453574f9535ff1be983a1abef841 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Thu, 19 Jan 2023 00:47:09 -0800 Subject: Use absl::string_view by value rather than by const reference while iterating over collections. PiperOrigin-RevId: 503088193 Change-Id: Ic1f239f3b0427e0fea1643ec0ce7baff45ad647d --- absl/strings/str_cat.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'absl/strings/str_cat.cc') diff --git a/absl/strings/str_cat.cc b/absl/strings/str_cat.cc index e5cb6d84..114a2ff2 100644 --- a/absl/strings/str_cat.cc +++ b/absl/strings/str_cat.cc @@ -144,12 +144,12 @@ namespace strings_internal { std::string CatPieces(std::initializer_list pieces) { std::string result; size_t total_size = 0; - for (const absl::string_view& piece : pieces) total_size += piece.size(); + for (absl::string_view piece : pieces) total_size += piece.size(); strings_internal::STLStringResizeUninitialized(&result, total_size); char* const begin = &result[0]; char* out = begin; - for (const absl::string_view& piece : pieces) { + for (absl::string_view piece : pieces) { const size_t this_size = piece.size(); if (this_size != 0) { memcpy(out, piece.data(), this_size); @@ -173,7 +173,7 @@ void AppendPieces(std::string* dest, std::initializer_list pieces) { size_t old_size = dest->size(); size_t total_size = old_size; - for (const absl::string_view& piece : pieces) { + for (absl::string_view piece : pieces) { ASSERT_NO_OVERLAP(*dest, piece); total_size += piece.size(); } @@ -181,7 +181,7 @@ void AppendPieces(std::string* dest, char* const begin = &(*dest)[0]; char* out = begin + old_size; - for (const absl::string_view& piece : pieces) { + for (absl::string_view piece : pieces) { const size_t this_size = piece.size(); if (this_size != 0) { memcpy(out, piece.data(), this_size); -- cgit v1.2.3