From a7473b65b80ce685c8aadb82527c3fc28baab393 Mon Sep 17 00:00:00 2001 From: Protobuf Team Bot Date: Tue, 20 Dec 2022 16:45:28 -0800 Subject: [PATCH] Don't call GetReflection(), unless the result will be used. PiperOrigin-RevId: 496782593 --- src/google/protobuf/util/message_differencer.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/google/protobuf/util/message_differencer.cc b/src/google/protobuf/util/message_differencer.cc index de0974fcc2..c8f6cfca47 100644 --- a/src/google/protobuf/util/message_differencer.cc +++ b/src/google/protobuf/util/message_differencer.cc @@ -638,12 +638,12 @@ bool MessageDifferencer::Compare(const Message& message1, return Compare(*data1, *data2, unpacked_any + 1, parent_fields); } } - const Reflection* reflection1 = message1.GetReflection(); - const Reflection* reflection2 = message2.GetReflection(); bool unknown_compare_result = true; // Ignore unknown fields in EQUIVALENT mode if (message_field_comparison_ != EQUIVALENT) { + const Reflection* reflection1 = message1.GetReflection(); + const Reflection* reflection2 = message2.GetReflection(); const UnknownFieldSet& unknown_field_set1 = reflection1->GetUnknownFields(message1); const UnknownFieldSet& unknown_field_set2 =