-
Notifications
You must be signed in to change notification settings - Fork 15.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[c#] Moved all message allocations to CreateTemplate(), making it easier to e.g. use pools to prevent GC load. #7722
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -104,7 +104,7 @@ void MessageFieldGenerator::GenerateMergingCode(io::Printer* printer) { | |
variables_, | ||
"if (other.$has_property_check$) {\n" | ||
" if ($has_not_property_check$) {\n" | ||
" $property_name$ = new $type_name$();\n" | ||
" $property_name$ = $type_name$.Parser.CreateTemplate();\n" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. after changing the codegen, you'd also need to regenerate the code in this repository. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. = do a build ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Build and then run https://github.com/protocolbuffers/protobuf/blob/master/csharp/generate_protos.sh. The updates to the generated files need to be commited (preferrably as a separate commit) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the overhead of using Parser.CreateTemplate? |
||
" }\n" | ||
" $property_name$.MergeFrom(other.$property_name$);\n" | ||
"}\n"); | ||
|
@@ -114,7 +114,7 @@ void MessageFieldGenerator::GenerateParsingCode(io::Printer* printer) { | |
printer->Print( | ||
variables_, | ||
"if ($has_not_property_check$) {\n" | ||
" $property_name$ = new $type_name$();\n" | ||
" $property_name$ = $type_name$.Parser.CreateTemplate();\n" | ||
"}\n"); | ||
if (descriptor_->type() == FieldDescriptor::Type::TYPE_MESSAGE) { | ||
printer->Print(variables_, "input.ReadMessage($property_name$);\n"); | ||
|
@@ -255,7 +255,7 @@ void MessageOneofFieldGenerator::GenerateMembers(io::Printer* printer) { | |
void MessageOneofFieldGenerator::GenerateMergingCode(io::Printer* printer) { | ||
printer->Print(variables_, | ||
"if ($property_name$ == null) {\n" | ||
" $property_name$ = new $type_name$();\n" | ||
" $property_name$ = $type_name$.Parser.CreateTemplate();\n" | ||
"}\n" | ||
"$property_name$.MergeFrom(other.$property_name$);\n"); | ||
} | ||
|
@@ -264,7 +264,7 @@ void MessageOneofFieldGenerator::GenerateParsingCode(io::Printer* printer) { | |
// TODO(jonskeet): We may be able to do better than this | ||
printer->Print( | ||
variables_, | ||
"$type_name$ subBuilder = new $type_name$();\n" | ||
"$type_name$ subBuilder = $type_name$.Parser.CreateTemplate();\n" | ||
"if ($has_property_check$) {\n" | ||
" subBuilder.MergeFrom($property_name$);\n" | ||
"}\n"); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍