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
43527448
Commit
43527448
authored
Jun 12, 2015
by
Jon Skeet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use Length to check string/bytes fields for emptiness - it's faster than an equality check.
parent
8fcde2ca
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
1 deletion
+7
-1
csharp_primitive_field.cc
...google/protobuf/compiler/csharp/csharp_primitive_field.cc
+7
-1
No files found.
src/google/protobuf/compiler/csharp/csharp_primitive_field.cc
View file @
43527448
...
...
@@ -52,6 +52,10 @@ PrimitiveFieldGenerator::PrimitiveFieldGenerator(
// TODO(jonskeet): Make this cleaner...
is_value_type
=
descriptor
->
type
()
!=
FieldDescriptor
::
TYPE_STRING
&&
descriptor
->
type
()
!=
FieldDescriptor
::
TYPE_BYTES
;
if
(
!
is_value_type
)
{
variables_
[
"has_property_check"
]
=
variables_
[
"property_name"
]
+
".Length != 0"
;
variables_
[
"other_has_property_check"
]
=
"other."
+
variables_
[
"property_name"
]
+
".Length != 0"
;
}
}
PrimitiveFieldGenerator
::~
PrimitiveFieldGenerator
()
{
...
...
@@ -90,9 +94,11 @@ void PrimitiveFieldGenerator::GenerateMergingCode(io::Printer* printer) {
}
void
PrimitiveFieldGenerator
::
GenerateParsingCode
(
io
::
Printer
*
printer
)
{
// Note: invoke the property setter rather than writing straight to the field,
// so that we can normalize "null to empty" for strings and bytes.
printer
->
Print
(
variables_
,
"$
name$_
= input.Read$capitalized_type_name$();
\n
"
);
"$
property_name$
= input.Read$capitalized_type_name$();
\n
"
);
}
void
PrimitiveFieldGenerator
::
GenerateSerializationCode
(
io
::
Printer
*
printer
)
{
...
...
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