Skip to content

Commit

Permalink
Fix ClangTidy warnings
Browse files Browse the repository at this point in the history
- Call std::string::insert to insert a character.
- Use assignment instead of CopyFrom.

PiperOrigin-RevId: 634610391
  • Loading branch information
protobuf-github-bot authored and copybara-github committed May 17, 2024
1 parent a521e6e commit 2f3242c
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/google/protobuf/compiler/parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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++) {
Expand Down

0 comments on commit 2f3242c

Please sign in to comment.