aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/compiler/cpp/cpp_message.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/google/protobuf/compiler/cpp/cpp_message.h')
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_message.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/google/protobuf/compiler/cpp/cpp_message.h b/src/google/protobuf/compiler/cpp/cpp_message.h
index b1e3fe21..3bdc0ed3 100644
--- a/src/google/protobuf/compiler/cpp/cpp_message.h
+++ b/src/google/protobuf/compiler/cpp/cpp_message.h
@@ -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_;