Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
5a33827e
Commit
5a33827e
authored
Jun 12, 2015
by
Jon Skeet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move Count checks into the serialization code
I wouldn't expect this to affect anything, but it appears to.
parent
5685e987
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
13 deletions
+12
-13
csharp_repeated_enum_field.cc
...le/protobuf/compiler/csharp/csharp_repeated_enum_field.cc
+3
-3
csharp_repeated_message_field.cc
...protobuf/compiler/csharp/csharp_repeated_message_field.cc
+3
-1
csharp_repeated_primitive_field.cc
...otobuf/compiler/csharp/csharp_repeated_primitive_field.cc
+6
-9
No files found.
src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc
View file @
5a33827e
...
...
@@ -80,11 +80,11 @@ void RepeatedEnumFieldGenerator::GenerateParsingCode(io::Printer* printer) {
}
void
RepeatedEnumFieldGenerator
::
GenerateSerializationCode
(
io
::
Printer
*
printer
)
{
// TODO(jonskeet): Originally, this checked for Count > 0 first.
// The Write* call should make that cheap though - no need to generate it every time.
printer
->
Print
(
variables_
,
"output.Write$packed$EnumArray($number$, $name$_);
\n
"
);
"if ($name$_.Count > 0) {
\n
"
" output.Write$packed$EnumArray($number$, $name$_);
\n
"
"}
\n
"
);
}
void
RepeatedEnumFieldGenerator
::
GenerateSerializedSizeCode
(
io
::
Printer
*
printer
)
{
...
...
src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc
View file @
5a33827e
...
...
@@ -83,7 +83,9 @@ void RepeatedMessageFieldGenerator::GenerateSerializationCode(io::Printer* print
// The Write* call should make that cheap though - no need to generate it every time.
printer
->
Print
(
variables_
,
"output.WriteMessageArray($number$, $name$_);
\n
"
);
"if ($name$_.Count > 0) {
\n
"
" output.WriteMessageArray($number$, $name$_);
\n
"
"}
\n
"
);
}
void
RepeatedMessageFieldGenerator
::
GenerateSerializedSizeCode
(
io
::
Printer
*
printer
)
{
...
...
src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc
View file @
5a33827e
...
...
@@ -49,6 +49,7 @@ namespace csharp {
RepeatedPrimitiveFieldGenerator
::
RepeatedPrimitiveFieldGenerator
(
const
FieldDescriptor
*
descriptor
,
int
fieldOrdinal
)
:
FieldGeneratorBase
(
descriptor
,
fieldOrdinal
)
{
variables_
[
"packed"
]
=
descriptor
->
is_packed
()
?
"Packed"
:
""
;
}
RepeatedPrimitiveFieldGenerator
::~
RepeatedPrimitiveFieldGenerator
()
{
...
...
@@ -79,15 +80,11 @@ void RepeatedPrimitiveFieldGenerator::GenerateParsingCode(io::Printer* printer)
void
RepeatedPrimitiveFieldGenerator
::
GenerateSerializationCode
(
io
::
Printer
*
printer
)
{
// TODO(jonskeet): Originally, this checked for Count > 0 first.
// The Write* call should make that cheap though - no need to generate it every time.
if
(
descriptor_
->
is_packed
())
{
printer
->
Print
(
variables_
,
"output.WritePacked$capitalized_type_name$Array($number$, $name$_);
\n
"
);
}
else
{
printer
->
Print
(
variables_
,
"output.Write$capitalized_type_name$Array($number$, $name$_);
\n
"
);
}
printer
->
Print
(
variables_
,
"if ($name$_.Count > 0) {
\n
"
" output.Write$packed$$capitalized_type_name$Array($number$, $name$_);
\n
"
"}
\n
"
);
}
void
RepeatedPrimitiveFieldGenerator
::
GenerateSerializedSizeCode
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment