Skip to content

Commit bd0db9c

Browse files
Automated Code Change
PiperOrigin-RevId: 824796020
1 parent 00aaca1 commit bd0db9c

File tree

8 files changed

+14
-18
lines changed

8 files changed

+14
-18
lines changed

src/google/protobuf/descriptor.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ class FlatAllocatorImpl {
506506
const std::string* AllocateStrings(In&&... in) {
507507
std::string* strings = AllocateArray<std::string>(sizeof...(in));
508508
std::string* res = strings;
509-
Fold({(*strings++ = std::string(std::forward<In>(in)))...});
509+
Fold({(*strings++ = std::forward<In>(in))...});
510510
return res;
511511
}
512512

@@ -3608,7 +3608,7 @@ class SourceLocationCommentPrinter {
36083608
}
36093609
}
36103610
void AddPostComment(std::string* output) {
3611-
if (have_source_loc_ && source_loc_.trailing_comments.size() > 0) {
3611+
if (have_source_loc_ && !source_loc_.trailing_comments.empty()) {
36123612
absl::StrAppend(output, FormatComment(source_loc_.trailing_comments));
36133613
}
36143614
}

src/google/protobuf/descriptor_database.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ void SimpleDescriptorDatabase::DescriptorIndex<Value>::FindAllFileNames(
347347

348348
bool SimpleDescriptorDatabase::Add(const FileDescriptorProto& file) {
349349
FileDescriptorProto* new_file = new FileDescriptorProto;
350-
new_file->CopyFrom(file);
350+
*new_file = file;
351351
return AddAndOwn(new_file);
352352
}
353353

@@ -394,7 +394,7 @@ bool SimpleDescriptorDatabase::MaybeCopy(
394394
const FileDescriptorProto* PROTOBUF_NULLABLE file,
395395
FileDescriptorProto* PROTOBUF_NONNULL output) {
396396
if (file == nullptr) return false;
397-
output->CopyFrom(*file);
397+
*output = *file;
398398
return true;
399399
}
400400

src/google/protobuf/descriptor_unittest.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,9 @@ using ::google::protobuf::internal::cpp::HasHasbitWithoutProfile;
9292
using ::google::protobuf::internal::cpp::HasPreservingUnknownEnumSemantics;
9393
using ::google::protobuf::internal::cpp::Utf8CheckMode;
9494
using ::testing::AnyOf;
95-
using ::testing::AtLeast;
9695
using ::testing::ElementsAre;
9796
using ::testing::HasSubstr;
9897
using ::testing::NotNull;
99-
using ::testing::Return;
10098

10199
absl::Status GetStatus(const absl::Status& s) { return s; }
102100
template <typename T>

src/google/protobuf/dynamic_message_unittest.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ TEST(DynamicMessageTest,
114114

115115
Reflection::ScratchSpace scratch;
116116
absl::string_view default_value = ref->GetStringView(*msg, field, scratch);
117-
ref->SetString(msg.get(), field, std::string("foo"));
117+
ref->SetString(msg.get(), field, "foo");
118118
EXPECT_EQ("foo", ref->GetStringView(*msg, field, scratch));
119119
msg->Clear();
120120
EXPECT_EQ(default_value, ref->GetStringView(*msg, field, scratch));

src/google/protobuf/extension_set_unittest.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -340,19 +340,19 @@ TEST(ExtensionSetTest, CopyFrom) {
340340
unittest::TestAllExtensions message1, message2;
341341

342342
TestUtil::SetAllExtensions(&message1);
343-
message2.CopyFrom(message1);
343+
message2 = message1;
344344
TestUtil::ExpectAllExtensionsSet(message2);
345-
message2.CopyFrom(message1); // exercise copy when fields already exist
345+
message2 = message1; // exercise copy when fields already exist
346346
TestUtil::ExpectAllExtensionsSet(message2);
347347
}
348348

349349
TEST(ExtensionSetTest, CopyFromPacked) {
350350
unittest::TestPackedExtensions message1, message2;
351351

352352
TestUtil::SetPackedExtensions(&message1);
353-
message2.CopyFrom(message1);
353+
message2 = message1;
354354
TestUtil::ExpectPackedExtensionsSet(message2);
355-
message2.CopyFrom(message1); // exercise copy when fields already exist
355+
message2 = message1; // exercise copy when fields already exist
356356
TestUtil::ExpectPackedExtensionsSet(message2);
357357
}
358358

src/google/protobuf/generated_message_util.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,12 +342,12 @@ bool IsNull(const void* ptr) {
342342

343343
template <>
344344
bool IsNull<WireFormatLite::TYPE_STRING>(const void* ptr) {
345-
return static_cast<const ArenaStringPtr*>(ptr)->Get().size() == 0;
345+
return static_cast<const ArenaStringPtr*>(ptr)->Get().empty();
346346
}
347347

348348
template <>
349349
bool IsNull<WireFormatLite::TYPE_BYTES>(const void* ptr) {
350-
return static_cast<const ArenaStringPtr*>(ptr)->Get().size() == 0;
350+
return static_cast<const ArenaStringPtr*>(ptr)->Get().empty();
351351
}
352352

353353
template <>

src/google/protobuf/map_field_test.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ namespace protobuf {
3333

3434
namespace internal {
3535

36-
using proto2_unittest::TestAllTypes;
37-
3836
struct MapFieldTestPeer {
3937
static auto GetArena(const RepeatedPtrFieldBase& v) { return v.GetArena(); }
4038
template <typename T>

src/google/protobuf/map_test.inc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2471,11 +2471,11 @@ TEST(GeneratedMapFieldTest, CopyFrom) {
24712471
UNITTEST::TestMap message1, message2;
24722472

24732473
MapTestUtil::SetMapFields(&message1);
2474-
message2.CopyFrom(message1);
2474+
message2 = message1;
24752475
MapTestUtil::ExpectMapFieldsSet(message2);
24762476

24772477
// Copying from self should be a no-op.
2478-
message2.CopyFrom(message2);
2478+
message2 = message2;
24792479
MapTestUtil::ExpectMapFieldsSet(message2);
24802480
}
24812481

@@ -2485,7 +2485,7 @@ TEST(GeneratedMapFieldTest, CopyFromMessageMap) {
24852485
(*message1.mutable_map_int32_message())[0].add_repeated_int32(100);
24862486
(*message2.mutable_map_int32_message())[0].add_repeated_int32(101);
24872487

2488-
message1.CopyFrom(message2);
2488+
message1 = message2;
24892489

24902490
// Checks repeated field is overwritten.
24912491
EXPECT_EQ(1, message1.map_int32_message().at(0).repeated_int32_size());

0 commit comments

Comments
 (0)