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_; |