Index: third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc |
diff --git a/third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc b/third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc |
index 240a6e0af19a75e5a140bebaa496626123c4a654..650f0381e5b12462221224231095f499ca3ec35a 100644 |
--- a/third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc |
+++ b/third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc |
@@ -80,7 +80,7 @@ int FixedSize(FieldDescriptor::Type type) { |
} |
void SetPrimitiveVariables(const FieldDescriptor* descriptor, |
- std::map<string, string>* variables, |
+ map<string, string>* variables, |
const Options& options) { |
SetCommonFieldVariables(descriptor, variables, options); |
(*variables)["type"] = PrimitiveTypeName(descriptor->cpp_type()); |
@@ -122,14 +122,14 @@ GenerateAccessorDeclarations(io::Printer* printer) const { |
void PrimitiveFieldGenerator:: |
GenerateInlineAccessorDefinitions(io::Printer* printer, bool is_inline) const { |
- std::map<string, string> variables(variables_); |
- variables["inline"] = is_inline ? "inline " : ""; |
+ map<string, string> variables(variables_); |
+ variables["inline"] = is_inline ? "inline" : ""; |
printer->Print(variables, |
- "$inline$$type$ $classname$::$name$() const {\n" |
+ "$inline$ $type$ $classname$::$name$() const {\n" |
" // @@protoc_insertion_point(field_get:$full_name$)\n" |
" return $name$_;\n" |
"}\n" |
- "$inline$void $classname$::set_$name$($type$ value) {\n" |
+ "$inline$ void $classname$::set_$name$($type$ value) {\n" |
" $set_hasbit$\n" |
" $name$_ = value;\n" |
" // @@protoc_insertion_point(field_set:$full_name$)\n" |
@@ -157,17 +157,12 @@ GenerateConstructorCode(io::Printer* printer) const { |
} |
void PrimitiveFieldGenerator:: |
-GenerateCopyConstructorCode(io::Printer* printer) const { |
- printer->Print(variables_, "$name$_ = from.$name$_;\n"); |
-} |
- |
-void PrimitiveFieldGenerator:: |
GenerateMergeFromCodedStream(io::Printer* printer) const { |
printer->Print(variables_, |
- "$set_hasbit$\n" |
"DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n" |
" $type$, $wire_format_field_type$>(\n" |
- " input, &$name$_)));\n"); |
+ " input, &$name$_)));\n" |
+ "$set_hasbit$\n"); |
} |
void PrimitiveFieldGenerator:: |
@@ -211,17 +206,17 @@ PrimitiveOneofFieldGenerator::~PrimitiveOneofFieldGenerator() {} |
void PrimitiveOneofFieldGenerator:: |
GenerateInlineAccessorDefinitions(io::Printer* printer, bool is_inline) const { |
- std::map<string, string> variables(variables_); |
- variables["inline"] = is_inline ? "inline " : ""; |
+ map<string, string> variables(variables_); |
+ variables["inline"] = is_inline ? "inline" : ""; |
printer->Print(variables, |
- "$inline$$type$ $classname$::$name$() const {\n" |
+ "$inline$ $type$ $classname$::$name$() const {\n" |
" // @@protoc_insertion_point(field_get:$full_name$)\n" |
" if (has_$name$()) {\n" |
" return $oneof_prefix$$name$_;\n" |
" }\n" |
" return $default$;\n" |
"}\n" |
- "$inline$void $classname$::set_$name$($type$ value) {\n" |
+ "$inline$ void $classname$::set_$name$($type$ value) {\n" |
" if (!has_$name$()) {\n" |
" clear_$oneof_name$();\n" |
" set_has_$name$();\n" |
@@ -245,7 +240,7 @@ void PrimitiveOneofFieldGenerator:: |
GenerateConstructorCode(io::Printer* printer) const { |
printer->Print( |
variables_, |
- " $classname$_default_oneof_instance_.$name$_ = $default$;\n"); |
+ " $classname$_default_oneof_instance_->$name$_ = $default$;\n"); |
} |
void PrimitiveOneofFieldGenerator:: |
@@ -302,28 +297,28 @@ GenerateAccessorDeclarations(io::Printer* printer) const { |
void RepeatedPrimitiveFieldGenerator:: |
GenerateInlineAccessorDefinitions(io::Printer* printer, bool is_inline) const { |
- std::map<string, string> variables(variables_); |
- variables["inline"] = is_inline ? "inline " : ""; |
+ map<string, string> variables(variables_); |
+ variables["inline"] = is_inline ? "inline" : ""; |
printer->Print(variables, |
- "$inline$$type$ $classname$::$name$(int index) const {\n" |
+ "$inline$ $type$ $classname$::$name$(int index) const {\n" |
" // @@protoc_insertion_point(field_get:$full_name$)\n" |
" return $name$_.Get(index);\n" |
"}\n" |
- "$inline$void $classname$::set_$name$(int index, $type$ value) {\n" |
+ "$inline$ void $classname$::set_$name$(int index, $type$ value) {\n" |
" $name$_.Set(index, value);\n" |
" // @@protoc_insertion_point(field_set:$full_name$)\n" |
"}\n" |
- "$inline$void $classname$::add_$name$($type$ value) {\n" |
+ "$inline$ void $classname$::add_$name$($type$ value) {\n" |
" $name$_.Add(value);\n" |
" // @@protoc_insertion_point(field_add:$full_name$)\n" |
"}\n"); |
printer->Print(variables, |
- "$inline$const ::google::protobuf::RepeatedField< $type$ >&\n" |
+ "$inline$ const ::google::protobuf::RepeatedField< $type$ >&\n" |
"$classname$::$name$() const {\n" |
" // @@protoc_insertion_point(field_list:$full_name$)\n" |
" return $name$_;\n" |
"}\n" |
- "$inline$::google::protobuf::RepeatedField< $type$ >*\n" |
+ "$inline$ ::google::protobuf::RepeatedField< $type$ >*\n" |
"$classname$::mutable_$name$() {\n" |
" // @@protoc_insertion_point(field_mutable_list:$full_name$)\n" |
" return &$name$_;\n" |
@@ -351,16 +346,11 @@ GenerateConstructorCode(io::Printer* printer) const { |
} |
void RepeatedPrimitiveFieldGenerator:: |
-GenerateCopyConstructorCode(io::Printer* printer) const { |
- printer->Print(variables_, "$name$_.CopyFrom(from.$name$_);\n"); |
-} |
- |
-void RepeatedPrimitiveFieldGenerator:: |
GenerateMergeFromCodedStream(io::Printer* printer) const { |
printer->Print(variables_, |
"DO_((::google::protobuf::internal::WireFormatLite::$repeated_reader$<\n" |
" $type$, $wire_format_field_type$>(\n" |
- " $tag_size$, $tag$u, input, this->mutable_$name$())));\n"); |
+ " $tag_size$, $tag$, input, this->mutable_$name$())));\n"); |
} |
void RepeatedPrimitiveFieldGenerator:: |
@@ -430,19 +420,18 @@ void RepeatedPrimitiveFieldGenerator:: |
GenerateByteSize(io::Printer* printer) const { |
printer->Print(variables_, |
"{\n" |
- " size_t data_size = 0;\n" |
- " unsigned int count = this->$name$_size();\n"); |
+ " int data_size = 0;\n"); |
printer->Indent(); |
int fixed_size = FixedSize(descriptor_->type()); |
if (fixed_size == -1) { |
printer->Print(variables_, |
- "for (unsigned int i = 0; i < count; i++) {\n" |
+ "for (int i = 0; i < this->$name$_size(); i++) {\n" |
" data_size += ::google::protobuf::internal::WireFormatLite::\n" |
" $declared_type$Size(this->$name$(i));\n" |
"}\n"); |
} else { |
printer->Print(variables_, |
- "data_size = $fixed_size$UL * count;\n"); |
+ "data_size = $fixed_size$ * this->$name$_size();\n"); |
} |
if (descriptor_->is_packed()) { |
@@ -451,16 +440,13 @@ GenerateByteSize(io::Printer* printer) const { |
" total_size += $tag_size$ +\n" |
" ::google::protobuf::internal::WireFormatLite::Int32Size(data_size);\n" |
"}\n" |
- "int cached_size = ::google::protobuf::internal::ToCachedSize(data_size);\n" |
"GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n" |
- "_$name$_cached_byte_size_ = cached_size;\n" |
+ "_$name$_cached_byte_size_ = data_size;\n" |
"GOOGLE_SAFE_CONCURRENT_WRITES_END();\n" |
"total_size += data_size;\n"); |
} else { |
printer->Print(variables_, |
- "total_size += $tag_size$ *\n" |
- " ::google::protobuf::internal::FromIntSize(this->$name$_size());\n" |
- "total_size += data_size;\n"); |
+ "total_size += $tag_size$ * this->$name$_size() + data_size;\n"); |
} |
printer->Outdent(); |
printer->Print("}\n"); |