Skip to content

Commit b846dbd

Browse files
Optimize proto2::MoveField for lazy extensions.
PiperOrigin-RevId: 826342531
1 parent 0a727cf commit b846dbd

File tree

10 files changed

+148
-0
lines changed

10 files changed

+148
-0
lines changed

src/google/protobuf/compiler/cpp/message.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2395,6 +2395,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* p) {
23952395
23962396
friend class $pb$::MessageLite;
23972397
friend class $pb$::Arena;
2398+
friend $pbi$::PrivateAccess;
23982399
template <typename T>
23992400
friend class $pb$::Arena::InternalHelper;
24002401
using InternalArenaConstructable_ = void;

src/google/protobuf/compiler/java/java_features.pb.h

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/google/protobuf/compiler/plugin.pb.h

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/google/protobuf/cpp_features.pb.h

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/google/protobuf/descriptor.pb.h

Lines changed: 34 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/google/protobuf/extension_set.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,21 @@ class PROTOBUF_EXPORT ExtensionSet {
625625
}
626626
#endif
627627

628+
// Moves an extension from one ExtensionSet to another.
629+
//
630+
// If the source extension does not exist, then destination extension is
631+
// freed (non-arena allocated) or cleared (arena allocated).
632+
//
633+
// If the destination extension already exists, it is overwritten.
634+
// If the destination extension does not exist, it is created.
635+
void MoveExtension(Arena* arena, int dst_number, ExtensionSet& src,
636+
int src_number);
637+
638+
bool IsLazy(int number) {
639+
Extension* extension = FindOrNull(number);
640+
return extension != nullptr && extension->is_lazy;
641+
}
642+
628643
private:
629644
template <typename Type>
630645
friend class PrimitiveTypeTraits;

src/google/protobuf/extension_set_heavy.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@
1414

1515
#include <cstddef>
1616
#include <cstdint>
17+
#include <cstring>
1718
#include <initializer_list>
1819
#include <string>
20+
#include <tuple>
21+
#include <utility>
1922
#include <variant>
2023
#include <vector>
2124

0 commit comments

Comments
 (0)