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
8af87de9
Unverified
Commit
8af87de9
authored
Jun 18, 2018
by
Feng Xiao
Committed by
GitHub
Jun 18, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2121 from mazurkin/issue-2108
issue-2108 [protoc/Java] Excessive copying on buildPartial()
parents
e264d6bc
aba6f7ef
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
44 additions
and
22 deletions
+44
-22
java_enum_field.cc
src/google/protobuf/compiler/java/java_enum_field.cc
+6
-2
java_lazy_message_field.cc
src/google/protobuf/compiler/java/java_lazy_message_field.cc
+1
-4
java_message_field.cc
src/google/protobuf/compiler/java/java_message_field.cc
+14
-9
java_primitive_field.cc
src/google/protobuf/compiler/java/java_primitive_field.cc
+17
-5
java_string_field.cc
src/google/protobuf/compiler/java/java_string_field.cc
+6
-2
No files found.
src/google/protobuf/compiler/java/java_enum_field.cc
View file @
8af87de9
...
...
@@ -305,11 +305,15 @@ GenerateBuildingCode(io::Printer* printer) const {
if
(
SupportFieldPresence
(
descriptor_
->
file
()))
{
printer
->
Print
(
variables_
,
"if ($get_has_field_bit_from_local$) {
\n
"
" result.$name$_ = $name$_;
\n
"
" $set_has_field_bit_to_local$;
\n
"
"} else {
\n
"
" result.$name$_ = $default_number$;
\n
"
"}
\n
"
);
}
else
{
printer
->
Print
(
variables_
,
"result.$name$_ = $name$_;
\n
"
);
}
printer
->
Print
(
variables_
,
"result.$name$_ = $name$_;
\n
"
);
}
void
ImmutableEnumFieldGenerator
::
...
...
src/google/protobuf/compiler/java/java_lazy_message_field.cc
View file @
8af87de9
...
...
@@ -233,12 +233,9 @@ void ImmutableLazyMessageFieldGenerator::
GenerateBuildingCode
(
io
::
Printer
*
printer
)
const
{
printer
->
Print
(
variables_
,
"if ($get_has_field_bit_from_local$) {
\n
"
" result.$name$_.set($name$_);
\n
"
" $set_has_field_bit_to_local$;
\n
"
"}
\n
"
);
printer
->
Print
(
variables_
,
"result.$name$_.set(
\n
"
" $name$_);
\n
"
);
}
void
ImmutableLazyMessageFieldGenerator
::
...
...
src/google/protobuf/compiler/java/java_message_field.cc
View file @
8af87de9
...
...
@@ -255,7 +255,7 @@ GenerateBuilderMembers(io::Printer* printer) const {
bool
support_field_presence
=
SupportFieldPresence
(
descriptor_
->
file
());
printer
->
Print
(
variables_
,
"private $type$ $name$_
= null
;
\n
"
);
"private $type$ $name$_;
\n
"
);
printer
->
Print
(
variables_
,
// If this builder is non-null, it is used and the other fields are
...
...
@@ -444,15 +444,20 @@ void ImmutableMessageFieldGenerator::
GenerateBuildingCode
(
io
::
Printer
*
printer
)
const
{
if
(
SupportFieldPresence
(
descriptor_
->
file
()))
{
printer
->
Print
(
variables_
,
"if ($get_has_field_bit_from_local$) {
\n
"
" $set_has_field_bit_to_local$;
\n
"
"}
\n
"
);
"if ($get_has_field_bit_from_local$) {
\n
"
);
printer
->
Indent
();
PrintNestedBuilderCondition
(
printer
,
"result.$name$_ = $name$_;
\n
"
,
"result.$name$_ = $name$Builder_.build();
\n
"
);
printer
->
Outdent
();
printer
->
Print
(
variables_
,
" $set_has_field_bit_to_local$;
\n
"
"}
\n
"
);
}
else
{
PrintNestedBuilderCondition
(
printer
,
"result.$name$_ = $name$_;
\n
"
,
"result.$name$_ = $name$Builder_.build();
\n
"
);
}
PrintNestedBuilderCondition
(
printer
,
"result.$name$_ = $name$_;
\n
"
,
"result.$name$_ = $name$Builder_.build();
\n
"
);
}
void
ImmutableMessageFieldGenerator
::
...
...
src/google/protobuf/compiler/java/java_primitive_field.cc
View file @
8af87de9
...
...
@@ -264,7 +264,9 @@ GenerateFieldBuilderInitializationCode(io::Printer* printer) const {
void
ImmutablePrimitiveFieldGenerator
::
GenerateInitializationCode
(
io
::
Printer
*
printer
)
const
{
printer
->
Print
(
variables_
,
"$name$_ = $default$;
\n
"
);
if
(
!
IsDefaultValueJavaDefault
(
descriptor_
))
{
printer
->
Print
(
variables_
,
"$name$_ = $default$;
\n
"
);
}
}
void
ImmutablePrimitiveFieldGenerator
::
...
...
@@ -294,11 +296,21 @@ GenerateBuildingCode(io::Printer* printer) const {
if
(
SupportFieldPresence
(
descriptor_
->
file
()))
{
printer
->
Print
(
variables_
,
"if ($get_has_field_bit_from_local$) {
\n
"
" $set_has_field_bit_to_local$;
\n
"
"}
\n
"
);
" result.$name$_ = $name$_;
\n
"
" $set_has_field_bit_to_local$;
\n
"
);
if
(
IsDefaultValueJavaDefault
(
descriptor_
))
{
printer
->
Print
(
variables_
,
"}
\n
"
);
}
else
{
printer
->
Print
(
variables_
,
"} else {
\n
"
" result.$name$_ = $default$;
\n
"
"}
\n
"
);
}
}
else
{
printer
->
Print
(
variables_
,
"result.$name$_ = $name$_;
\n
"
);
}
printer
->
Print
(
variables_
,
"result.$name$_ = $name$_;
\n
"
);
}
void
ImmutablePrimitiveFieldGenerator
::
...
...
src/google/protobuf/compiler/java/java_string_field.cc
View file @
8af87de9
...
...
@@ -405,11 +405,15 @@ GenerateBuildingCode(io::Printer* printer) const {
if
(
SupportFieldPresence
(
descriptor_
->
file
()))
{
printer
->
Print
(
variables_
,
"if ($get_has_field_bit_from_local$) {
\n
"
" result.$name$_ = $name$_;
\n
"
" $set_has_field_bit_to_local$;
\n
"
"} else {
\n
"
" result.$name$_ = $default$;
\n
"
"}
\n
"
);
}
else
{
printer
->
Print
(
variables_
,
"result.$name$_ = $name$_;
\n
"
);
}
printer
->
Print
(
variables_
,
"result.$name$_ = $name$_;
\n
"
);
}
void
ImmutableStringFieldGenerator
::
...
...
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