Fix string copy in MessageDifferencer::Compare()

This CL fixes an unnecessary string copy. `Message::GetTypeName()` always
returns a copy, but we can avoid this by relying on `Descriptor::full_name()`
instead.

PiperOrigin-RevId: 675237607
pull/18336/head
Adam Cozzette 5 months ago committed by Copybara-Service
parent 51adb09adc
commit 1a83839831
  1. 2
      src/google/protobuf/util/message_differencer.cc

@ -612,7 +612,7 @@ bool MessageDifferencer::Compare(const Message& message1,
const Message& message2, int unpacked_any,
std::vector<SpecificField>* parent_fields) {
// Expand google.protobuf.Any payload if possible.
if (message1.GetTypeName() == internal::kAnyFullTypeName) {
if (message1.GetDescriptor()->full_name() == internal::kAnyFullTypeName) {
std::unique_ptr<Message> data1;
std::unique_ptr<Message> data2;
if (unpack_any_field_.UnpackAny(message1, &data1) &&

Loading…
Cancel
Save