Skip to content

Commit e10f2cf

Browse files
Automated Code Change
PiperOrigin-RevId: 757554713
1 parent 3d043e8 commit e10f2cf

9 files changed

+15
-23
lines changed

src/google/protobuf/descriptor.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ class FlatAllocatorImpl {
499499
const std::string* AllocateStrings(In&&... in) {
500500
std::string* strings = AllocateArray<std::string>(sizeof...(in));
501501
std::string* res = strings;
502-
Fold({(*strings++ = std::string(std::forward<In>(in)))...});
502+
Fold({(*strings++ = std::forward<In>(in))...});
503503
return res;
504504
}
505505

@@ -3600,7 +3600,7 @@ class SourceLocationCommentPrinter {
36003600
}
36013601
}
36023602
void AddPostComment(std::string* output) {
3603-
if (have_source_loc_ && source_loc_.trailing_comments.size() > 0) {
3603+
if (have_source_loc_ && !source_loc_.trailing_comments.empty()) {
36043604
absl::StrAppend(output, FormatComment(source_loc_.trailing_comments));
36053605
}
36063606
}

src/google/protobuf/descriptor_database.cc

+2-2
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/extension_set_unittest.cc

+6-6
Original file line numberDiff line numberDiff line change
@@ -254,19 +254,19 @@ TEST(ExtensionSetTest, CopyFrom) {
254254
unittest::TestAllExtensions message1, message2;
255255

256256
TestUtil::SetAllExtensions(&message1);
257-
message2.CopyFrom(message1);
257+
message2 = message1;
258258
TestUtil::ExpectAllExtensionsSet(message2);
259-
message2.CopyFrom(message1); // exercise copy when fields already exist
259+
message2 = message1; // exercise copy when fields already exist
260260
TestUtil::ExpectAllExtensionsSet(message2);
261261
}
262262

263263
TEST(ExtensionSetTest, CopyFromPacked) {
264264
unittest::TestPackedExtensions message1, message2;
265265

266266
TestUtil::SetPackedExtensions(&message1);
267-
message2.CopyFrom(message1);
267+
message2 = message1;
268268
TestUtil::ExpectPackedExtensionsSet(message2);
269-
message2.CopyFrom(message1); // exercise copy when fields already exist
269+
message2 = message1; // exercise copy when fields already exist
270270
TestUtil::ExpectPackedExtensionsSet(message2);
271271
}
272272

@@ -810,8 +810,8 @@ TEST(ExtensionSetTest, SpaceUsedExcludingSelf) {
810810
const int base_size = message.SpaceUsedLong();
811811
unittest::ForeignMessage foreign;
812812
foreign.set_c(42);
813-
message.MutableExtension(unittest::optional_foreign_message_extension)
814-
->CopyFrom(foreign);
813+
*message.MutableExtension(unittest::optional_foreign_message_extension) =
814+
foreign;
815815
int min_expected_size = base_size + foreign.SpaceUsedLong();
816816
EXPECT_LE(min_expected_size, message.SpaceUsedLong());
817817
}

src/google/protobuf/generated_message_reflection.cc

-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ using google::protobuf::internal::ArenaStringPtr;
6868
using google::protobuf::internal::DescriptorTable;
6969
using google::protobuf::internal::ExtensionSet;
7070
using google::protobuf::internal::GenericTypeHandler;
71-
using google::protobuf::internal::GetEmptyString;
7271
using google::protobuf::internal::InlinedStringField;
7372
using google::protobuf::internal::InternalMetadata;
7473
using google::protobuf::internal::LazyField;

src/google/protobuf/generated_message_util.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -337,12 +337,12 @@ bool IsNull(const void* ptr) {
337337

338338
template <>
339339
bool IsNull<WireFormatLite::TYPE_STRING>(const void* ptr) {
340-
return static_cast<const ArenaStringPtr*>(ptr)->Get().size() == 0;
340+
return static_cast<const ArenaStringPtr*>(ptr)->Get().empty();
341341
}
342342

343343
template <>
344344
bool IsNull<WireFormatLite::TYPE_BYTES>(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 <>

src/google/protobuf/map_field_test.cc

-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ namespace protobuf {
3434

3535
namespace internal {
3636

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

src/google/protobuf/map_test.inc

+3-3
Original file line numberDiff line numberDiff line change
@@ -2448,11 +2448,11 @@ TEST(GeneratedMapFieldTest, CopyFrom) {
24482448
UNITTEST::TestMap message1, message2;
24492449

24502450
MapTestUtil::SetMapFields(&message1);
2451-
message2.CopyFrom(message1);
2451+
message2 = message1;
24522452
MapTestUtil::ExpectMapFieldsSet(message2);
24532453

24542454
// Copying from self should be a no-op.
2455-
message2.CopyFrom(message2);
2455+
message2 = message2;
24562456
MapTestUtil::ExpectMapFieldsSet(message2);
24572457
}
24582458

@@ -2462,7 +2462,7 @@ TEST(GeneratedMapFieldTest, CopyFromMessageMap) {
24622462
(*message1.mutable_map_int32_message())[0].add_repeated_int32(100);
24632463
(*message2.mutable_map_int32_message())[0].add_repeated_int32(101);
24642464

2465-
message1.CopyFrom(message2);
2465+
message1 = message2;
24662466

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

src/google/protobuf/no_field_presence_map_test.cc

-4
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,11 @@ namespace google {
2525
namespace protobuf {
2626
namespace {
2727

28-
using ::proto2_nofieldpresence_unittest::ExplicitForeignMessage;
2928
using ::proto2_nofieldpresence_unittest::FOREIGN_BAZ;
3029
using ::proto2_nofieldpresence_unittest::FOREIGN_FOO;
31-
using ::proto2_nofieldpresence_unittest::ForeignMessage;
3230
using ::proto2_nofieldpresence_unittest::TestAllMapTypes;
3331
using ::testing::Eq;
34-
using ::testing::Gt;
3532
using ::testing::Not;
36-
using ::testing::StrEq;
3733
using ::testing::UnorderedPointwise;
3834

3935
// Custom gmock matchers to simplify testing for map entries.

src/google/protobuf/no_field_presence_test.cc

-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ using ::proto2_nofieldpresence_unittest::TestAllTypes;
3434
using ::testing::Eq;
3535
using ::testing::Gt;
3636
using ::testing::IsEmpty;
37-
using ::testing::Not;
3837
using ::testing::StrEq;
3938
using ::testing::UnorderedPointwise;
4039

0 commit comments

Comments
 (0)