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
3e5bd2fd
Commit
3e5bd2fd
authored
Oct 25, 2017
by
Jon Skeet
Committed by
Jon Skeet
Dec 09, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
C# code generation changes to use bitwise comparisons for doubles
parent
f3e9a65d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
12 deletions
+30
-12
csharp_primitive_field.cc
...google/protobuf/compiler/csharp/csharp_primitive_field.cc
+14
-6
csharp_wrapper_field.cc
src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc
+16
-6
No files found.
src/google/protobuf/compiler/csharp/csharp_primitive_field.cc
View file @
3e5bd2fd
...
...
@@ -137,14 +137,22 @@ void PrimitiveFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer) {
}
void
PrimitiveFieldGenerator
::
WriteHash
(
io
::
Printer
*
printer
)
{
printer
->
Print
(
variables_
,
"if ($has_property_check$) hash ^= $property_name$.GetHashCode();
\n
"
);
const
char
*
text
=
"if ($has_property_check$) hash ^= $property_name$.GetHashCode();
\n
"
;
if
(
descriptor_
->
type
()
==
FieldDescriptor
::
TYPE_FLOAT
)
{
text
=
"if ($has_property_check$) hash ^= pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.GetHashCode($property_name$);
\n
"
;
}
else
if
(
descriptor_
->
type
()
==
FieldDescriptor
::
TYPE_DOUBLE
)
{
text
=
"if ($has_property_check$) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode($property_name$);
\n
"
;
}
printer
->
Print
(
variables_
,
text
);
}
void
PrimitiveFieldGenerator
::
WriteEquals
(
io
::
Printer
*
printer
)
{
printer
->
Print
(
variables_
,
"if ($property_name$ != other.$property_name$) return false;
\n
"
);
const
char
*
text
=
"if ($property_name$ != other.$property_name$) return false;
\n
"
;
if
(
descriptor_
->
type
()
==
FieldDescriptor
::
TYPE_FLOAT
)
{
text
=
"if (!pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.Equals($property_name$, other.$property_name$)) return false;
\n
"
;
}
else
if
(
descriptor_
->
type
()
==
FieldDescriptor
::
TYPE_DOUBLE
)
{
text
=
"if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals($property_name$, other.$property_name$)) return false;
\n
"
;
}
printer
->
Print
(
variables_
,
text
);
}
void
PrimitiveFieldGenerator
::
WriteToString
(
io
::
Printer
*
printer
)
{
printer
->
Print
(
...
...
src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc
View file @
3e5bd2fd
...
...
@@ -120,15 +120,25 @@ void WrapperFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer) {
}
void
WrapperFieldGenerator
::
WriteHash
(
io
::
Printer
*
printer
)
{
printer
->
Print
(
variables_
,
"if ($has_property_check$) hash ^= $property_name$.GetHashCode();
\n
"
);
const
char
*
text
=
"if ($has_property_check$) hash ^= $property_name$.GetHashCode();
\n
"
;
if
(
descriptor_
->
message_type
()
->
field
(
0
)
->
type
()
==
FieldDescriptor
::
TYPE_FLOAT
)
{
text
=
"if ($has_property_check$) hash ^= pbc::ProtobufEqualityComparers.BitwiseNullableSingleEqualityComparer.GetHashCode($property_name$);
\n
"
;
}
else
if
(
descriptor_
->
message_type
()
->
field
(
0
)
->
type
()
==
FieldDescriptor
::
TYPE_DOUBLE
)
{
text
=
"if ($has_property_check$) hash ^= pbc::ProtobufEqualityComparers.BitwiseNullableDoubleEqualityComparer.GetHashCode($property_name$);
\n
"
;
}
printer
->
Print
(
variables_
,
text
);
}
void
WrapperFieldGenerator
::
WriteEquals
(
io
::
Printer
*
printer
)
{
printer
->
Print
(
variables_
,
"if ($property_name$ != other.$property_name$) return false;
\n
"
);
const
char
*
text
=
"if ($property_name$ != other.$property_name$) return false;
\n
"
;
if
(
descriptor_
->
message_type
()
->
field
(
0
)
->
type
()
==
FieldDescriptor
::
TYPE_FLOAT
)
{
text
=
"if (!pbc::ProtobufEqualityComparers.BitwiseNullableSingleEqualityComparer.Equals($property_name$, other.$property_name$)) return false;
\n
"
;
}
else
if
(
descriptor_
->
message_type
()
->
field
(
0
)
->
type
()
==
FieldDescriptor
::
TYPE_DOUBLE
)
{
text
=
"if (!pbc::ProtobufEqualityComparers.BitwiseNullableDoubleEqualityComparer.Equals($property_name$, other.$property_name$)) return false;
\n
"
;
}
printer
->
Print
(
variables_
,
text
);
}
void
WrapperFieldGenerator
::
WriteToString
(
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