simpler, cheaper callback to LazyStringOutputStream

pull/2525/head
Camillo Lugaresi 8 years ago
parent 4e229c8b5c
commit abe172564e
  1. 16
      src/google/protobuf/compiler/cpp/cpp_message.cc

@ -1661,18 +1661,6 @@ void MessageGenerator::
GenerateClassMethods(io::Printer* printer) { GenerateClassMethods(io::Printer* printer) {
if (IsMapEntryMessage(descriptor_)) return; if (IsMapEntryMessage(descriptor_)) return;
// mutable_unknown_fields wrapper function for LazyStringOutputStream
// callback.
if (PreserveUnknownFields(descriptor_) &&
!UseUnknownFieldSet(descriptor_->file(), options_)) {
printer->Print(
"static ::std::string* MutableUnknownFieldsFor$classname$(\n"
" $classname$* ptr) {\n"
" return ptr->mutable_unknown_fields();\n"
"}\n"
"\n",
"classname", classname_);
}
if (IsAnyMessage(descriptor_)) { if (IsAnyMessage(descriptor_)) {
printer->Print( printer->Print(
"void $classname$::PackFrom(const ::google::protobuf::Message& message) {\n" "void $classname$::PackFrom(const ::google::protobuf::Message& message) {\n"
@ -2936,8 +2924,8 @@ GenerateMergeFromCodedStream(io::Printer* printer) {
// on the CodedOutputStream. // on the CodedOutputStream.
printer->Print( printer->Print(
" ::google::protobuf::io::LazyStringOutputStream unknown_fields_string(\n" " ::google::protobuf::io::LazyStringOutputStream unknown_fields_string(\n"
" NewPermanentCallback(\n" " ::google::protobuf::NewPermanentCallback(&_internal_metadata_,\n"
" &MutableUnknownFieldsFor$classname$, this));\n" " &::google::protobuf::internal::InternalMetadataWithArenaLite::mutable_unknown_fields));\n"
" ::google::protobuf::io::CodedOutputStream unknown_fields_stream(\n" " ::google::protobuf::io::CodedOutputStream unknown_fields_stream(\n"
" &unknown_fields_string, false);\n", " &unknown_fields_string, false);\n",
"classname", classname_); "classname", classname_);

Loading…
Cancel
Save