Skip to content

Commit

Permalink
Use newly introduced Clone method in LazyField in order to avoid …
Browse files Browse the repository at this point in the history
…looking up prototype (`GetPrototypeForLazyMessage`) during copy.

PiperOrigin-RevId: 700667703
  • Loading branch information
goldvitaly authored and copybara-github committed Nov 27, 2024
1 parent 525e16a commit f66e49c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 2 additions & 4 deletions src/google/protobuf/extension_set.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1092,10 +1092,8 @@ void ExtensionSet::InternalExtensionMergeFromIntoUninitializedExtension(
case WireFormatLite::CPPTYPE_MESSAGE: {
if (other_extension.is_lazy) {
dst_extension.ptr.lazymessage_value =
other_extension.ptr.lazymessage_value->New(arena_);
dst_extension.ptr.lazymessage_value->MergeFrom(
GetPrototypeForLazyMessage(extendee, number),
*other_extension.ptr.lazymessage_value, arena_, other_arena);
other_extension.ptr.lazymessage_value->Clone(
arena_, *other_extension.ptr.lazymessage_value, other_arena);
} else {
dst_extension.ptr.message_value =
other_extension.ptr.message_value->New(arena_);
Expand Down
4 changes: 3 additions & 1 deletion src/google/protobuf/extension_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,9 @@ class PROTOBUF_EXPORT ExtensionSet {
LazyMessageExtension& operator=(const LazyMessageExtension&) = delete;
virtual ~LazyMessageExtension() = default;

virtual LazyMessageExtension* New(Arena* arena) const = 0;
virtual LazyMessageExtension* Clone(Arena* arena,
const LazyMessageExtension& other,
Arena* other_arena) const = 0;
virtual const MessageLite& GetMessage(const MessageLite& prototype,
Arena* arena) const = 0;
virtual const MessageLite& GetMessageIgnoreUnparsed(
Expand Down

0 comments on commit f66e49c

Please sign in to comment.