aboutsummaryrefslogtreecommitdiff
path: root/src/google/protobuf/compiler/cpp/cpp_message.h
diff options
context:
space:
mode:
authorBo Yang <teboring@google.com>2016-09-19 13:45:07 -0700
committerBo Yang <teboring@google.com>2016-10-10 11:23:36 -0700
commitcc8ca5b6a5478b40546d4206392eb1471454460d (patch)
treec0b45abfa16d7d373a6ea8f7fe50f1de00ab938e /src/google/protobuf/compiler/cpp/cpp_message.h
parent337a028bb65ccca4dda768695950b5aba53ae2c9 (diff)
downloadprotobuf-cc8ca5b6a5478b40546d4206392eb1471454460d.tar.gz
protobuf-cc8ca5b6a5478b40546d4206392eb1471454460d.tar.bz2
protobuf-cc8ca5b6a5478b40546d4206392eb1471454460d.zip
Integrate internal changes
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_;