Skip to content

Commit

Permalink
improve readability
Browse files Browse the repository at this point in the history
  • Loading branch information
jtattermusch committed May 27, 2020
1 parent da35f6f commit 6a92d59
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 55 deletions.
14 changes: 5 additions & 9 deletions src/google/protobuf/compiler/csharp/csharp_map_field.cc
Expand Up @@ -98,15 +98,11 @@ void MapFieldGenerator::GenerateParsingCode(io::Printer* printer) {
}

void MapFieldGenerator::GenerateParsingCode(io::Printer* printer, bool use_parse_context) {
if (use_parse_context) {
printer->Print(
variables_,
"$name$_.AddEntriesFrom(ref input, _map_$name$_codec);\n");
} else {
printer->Print(
variables_,
"$name$_.AddEntriesFrom(input, _map_$name$_codec);\n");
}
printer->Print(
variables_,
use_parse_context
? "$name$_.AddEntriesFrom(ref input, _map_$name$_codec);\n"
: "$name$_.AddEntriesFrom(input, _map_$name$_codec);\n");
}

void MapFieldGenerator::GenerateSerializationCode(io::Printer* printer) {
Expand Down
Expand Up @@ -82,15 +82,11 @@ void RepeatedEnumFieldGenerator::GenerateParsingCode(io::Printer* printer) {
}

void RepeatedEnumFieldGenerator::GenerateParsingCode(io::Printer* printer, bool use_parse_context) {
if (use_parse_context) {
printer->Print(
variables_,
"$name$_.AddEntriesFrom(ref input, _repeated_$name$_codec);\n");
} else {
printer->Print(
variables_,
"$name$_.AddEntriesFrom(input, _repeated_$name$_codec);\n");
}
printer->Print(
variables_,
use_parse_context
? "$name$_.AddEntriesFrom(ref input, _repeated_$name$_codec);\n"
: "$name$_.AddEntriesFrom(input, _repeated_$name$_codec);\n");
}

void RepeatedEnumFieldGenerator::GenerateSerializationCode(io::Printer* printer) {
Expand Down
Expand Up @@ -97,15 +97,11 @@ void RepeatedMessageFieldGenerator::GenerateParsingCode(io::Printer* printer) {
}

void RepeatedMessageFieldGenerator::GenerateParsingCode(io::Printer* printer, bool use_parse_context) {
if (use_parse_context) {
printer->Print(
variables_,
"$name$_.AddEntriesFrom(ref input, _repeated_$name$_codec);\n");
} else {
printer->Print(
variables_,
"$name$_.AddEntriesFrom(input, _repeated_$name$_codec);\n");
}
printer->Print(
variables_,
use_parse_context
? "$name$_.AddEntriesFrom(ref input, _repeated_$name$_codec);\n"
: "$name$_.AddEntriesFrom(input, _repeated_$name$_codec);\n");
}

void RepeatedMessageFieldGenerator::GenerateSerializationCode(io::Printer* printer) {
Expand Down
Expand Up @@ -82,15 +82,11 @@ void RepeatedPrimitiveFieldGenerator::GenerateParsingCode(io::Printer* printer)
}

void RepeatedPrimitiveFieldGenerator::GenerateParsingCode(io::Printer* printer, bool use_parse_context) {
if (use_parse_context) {
printer->Print(
variables_,
"$name$_.AddEntriesFrom(ref input, _repeated_$name$_codec);\n");
} else {
printer->Print(
variables_,
"$name$_.AddEntriesFrom(input, _repeated_$name$_codec);\n");
}
printer->Print(
variables_,
use_parse_context
? "$name$_.AddEntriesFrom(ref input, _repeated_$name$_codec);\n"
: "$name$_.AddEntriesFrom(input, _repeated_$name$_codec);\n");
}

void RepeatedPrimitiveFieldGenerator::GenerateSerializationCode(io::Printer* printer) {
Expand Down
30 changes: 11 additions & 19 deletions src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc
Expand Up @@ -118,21 +118,17 @@ void WrapperFieldGenerator::GenerateParsingCode(io::Printer* printer) {
}

void WrapperFieldGenerator::GenerateParsingCode(io::Printer* printer, bool use_parse_context) {
if (use_parse_context) {
printer->Print(
variables_,
"$type_name$ value = _single_$name$_codec.Read(ref input);\n"
printer->Print(
variables_,
use_parse_context
? "$type_name$ value = _single_$name$_codec.Read(ref input);\n"
"if ($has_not_property_check$ || value != $default_value$) {\n"
" $property_name$ = value;\n"
"}\n");
} else {
printer->Print(
variables_,
"$type_name$ value = _single_$name$_codec.Read(input);\n"
"}\n"
: "$type_name$ value = _single_$name$_codec.Read(input);\n"
"if ($has_not_property_check$ || value != $default_value$) {\n"
" $property_name$ = value;\n"
"}\n");
}
}

void WrapperFieldGenerator::GenerateSerializationCode(io::Printer* printer) {
Expand Down Expand Up @@ -265,15 +261,11 @@ void WrapperOneofFieldGenerator::GenerateParsingCode(io::Printer* printer) {
}

void WrapperOneofFieldGenerator::GenerateParsingCode(io::Printer* printer, bool use_parse_context) {
if (use_parse_context) {
printer->Print(
variables_,
"$property_name$ = _oneof_$name$_codec.Read(ref input);\n");
} else {
printer->Print(
variables_,
"$property_name$ = _oneof_$name$_codec.Read(input);\n");
}
printer->Print(
variables_,
use_parse_context
? "$property_name$ = _oneof_$name$_codec.Read(ref input);\n"
: "$property_name$ = _oneof_$name$_codec.Read(input);\n");
}

void WrapperOneofFieldGenerator::GenerateSerializationCode(io::Printer* printer) {
Expand Down

0 comments on commit 6a92d59

Please sign in to comment.