Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(157)

Unified Diff: third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_message.h

Issue 2495533002: third_party/protobuf: Update to HEAD (83d681ee2c) (Closed)
Patch Set: Update to new HEAD (b7632464b4) + restore GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_message.h
diff --git a/third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_message.h b/third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_message.h
index 31223e13ff4d7395940a4fb04cd0c48153f2303b..3bdc0ed3975dfa1cdeb6b768ff0added5ef4ab3f 100644
--- a/third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_message.h
+++ b/third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_message.h
@@ -66,7 +66,7 @@ class MessageGenerator {
// Header stuff.
- // Return names for foward declarations of this class and all its nested
+ // Return names for forward declarations of this class and all its nested
// types. A given key in {class,enum}_names will map from a class name to the
// descriptor that was responsible for its inclusion in the map. This can be
// used to associate the descriptor with the code generated for it.
@@ -165,6 +165,11 @@ class MessageGenerator {
void GenerateSerializeOneField(io::Printer* printer,
const FieldDescriptor* field,
bool unbounded);
+ // Generate a switch statement to serialize 2+ fields from the same oneof.
+ // Or, if fields.size() == 1, just call GenerateSerializeOneField().
+ void GenerateSerializeOneofFields(
+ io::Printer* printer, const vector<const FieldDescriptor*>& fields,
+ bool to_array);
void GenerateSerializeOneExtensionRange(
io::Printer* printer, const Descriptor::ExtensionRange* range,
bool unbounded);
@@ -189,6 +194,11 @@ class MessageGenerator {
string classname_;
Options options_;
FieldGeneratorMap field_generators_;
+ // optimized_order_ is the order we layout the message's fields in the class.
+ // This is reused to initialize the fields in-order for cache efficiency.
+ //
+ // optimized_order_ excludes oneof fields.
+ vector<const FieldDescriptor *> optimized_order_;
vector< vector<string> > runs_of_fields_; // that might be trivially cleared
google::protobuf::scoped_array<google::protobuf::scoped_ptr<MessageGenerator> > nested_generators_;
google::protobuf::scoped_array<google::protobuf::scoped_ptr<EnumGenerator> > enum_generators_;

Powered by Google App Engine
This is Rietveld 408576698