From 2f3242c576504459621fd7d78bbccf39bfaa49c5 Mon Sep 17 00:00:00 2001 From: Protobuf Team Bot Date: Thu, 16 May 2024 20:04:00 -0700 Subject: [PATCH] Fix ClangTidy warnings - Call std::string::insert to insert a character. - Use assignment instead of CopyFrom. PiperOrigin-RevId: 634610391 --- src/google/protobuf/compiler/parser.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/google/protobuf/compiler/parser.cc b/src/google/protobuf/compiler/parser.cc index c2595fe74a..1f5ce3d0aa 100644 --- a/src/google/protobuf/compiler/parser.cc +++ b/src/google/protobuf/compiler/parser.cc @@ -836,10 +836,10 @@ PROTOBUF_NOINLINE static void GenerateSyntheticOneofs( // Avoid prepending a double-underscore because such names are // reserved in C++. if (oneof_name.empty() || oneof_name[0] != '_') { - oneof_name = '_' + oneof_name; + oneof_name.insert(0, "_"); } while (names.count(oneof_name) > 0) { - oneof_name = 'X' + oneof_name; + oneof_name.insert(0, "X"); } names.insert(oneof_name); @@ -1797,8 +1797,7 @@ bool Parser::ParseExtensions(DescriptorProto* message, // Then copy the extension range options to all of the other ranges we've // parsed. for (int i = old_range_size + 1; i < message->extension_range_size(); i++) { - message->mutable_extension_range(i)->mutable_options()->CopyFrom( - *options); + *message->mutable_extension_range(i)->mutable_options() = *options; } // and copy source locations to the other ranges, too for (int i = old_range_size; i < message->extension_range_size(); i++) {