aboutsummaryrefslogtreecommitdiff
path: root/src/google/protobuf/compiler/java/java_string_field.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/google/protobuf/compiler/java/java_string_field.cc')
-rw-r--r--src/google/protobuf/compiler/java/java_string_field.cc30
1 files changed, 2 insertions, 28 deletions
diff --git a/src/google/protobuf/compiler/java/java_string_field.cc b/src/google/protobuf/compiler/java/java_string_field.cc
index 7f757e47..b67eeb53 100644
--- a/src/google/protobuf/compiler/java/java_string_field.cc
+++ b/src/google/protobuf/compiler/java/java_string_field.cc
@@ -87,8 +87,7 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor,
// by the proto compiler
(*variables)["deprecation"] = descriptor->options().deprecated()
? "@java.lang.Deprecated " : "";
- (*variables)["on_changed"] =
- HasDescriptorMethods(descriptor->containing_type()) ? "onChanged();" : "";
+ (*variables)["on_changed"] = "onChanged();";
if (SupportFieldPresence(descriptor->file())) {
// For singular messages and builders, one bit is used for the hasField bit.
@@ -408,15 +407,6 @@ GenerateParsingCode(io::Printer* printer) const {
"java.lang.String s = input.readStringRequireUtf8();\n"
"$set_has_field_bit_message$\n"
"$name$_ = s;\n");
- } else if (!HasDescriptorMethods(descriptor_->file())) {
- // Lite runtime should attempt to reduce allocations by attempting to
- // construct the string directly from the input stream buffer. This avoids
- // spurious intermediary ByteString allocations, cutting overall allocations
- // in half.
- printer->Print(variables_,
- "java.lang.String s = input.readString();\n"
- "$set_has_field_bit_message$\n"
- "$name$_ = s;\n");
} else {
printer->Print(variables_,
"com.google.protobuf.ByteString bs = input.readBytes();\n"
@@ -668,15 +658,6 @@ GenerateParsingCode(io::Printer* printer) const {
"java.lang.String s = input.readStringRequireUtf8();\n"
"$set_oneof_case_message$;\n"
"$oneof_name$_ = s;\n");
- } else if (!HasDescriptorMethods(descriptor_->file())) {
- // Lite runtime should attempt to reduce allocations by attempting to
- // construct the string directly from the input stream buffer. This avoids
- // spurious intermediary ByteString allocations, cutting overall allocations
- // in half.
- printer->Print(variables_,
- "java.lang.String s = input.readString();\n"
- "$set_oneof_case_message$;\n"
- "$oneof_name$_ = s;\n");
} else {
printer->Print(variables_,
"com.google.protobuf.ByteString bs = input.readBytes();\n"
@@ -934,13 +915,6 @@ GenerateParsingCode(io::Printer* printer) const {
if (CheckUtf8(descriptor_)) {
printer->Print(variables_,
"java.lang.String s = input.readStringRequireUtf8();\n");
- } else if (!HasDescriptorMethods(descriptor_->file())) {
- // Lite runtime should attempt to reduce allocations by attempting to
- // construct the string directly from the input stream buffer. This avoids
- // spurious intermediary ByteString allocations, cutting overall allocations
- // in half.
- printer->Print(variables_,
- "java.lang.String s = input.readString();\n");
} else {
printer->Print(variables_,
"com.google.protobuf.ByteString bs = input.readBytes();\n");
@@ -950,7 +924,7 @@ GenerateParsingCode(io::Printer* printer) const {
" $name$_ = new com.google.protobuf.LazyStringArrayList();\n"
" $set_mutable_bit_parser$;\n"
"}\n");
- if (CheckUtf8(descriptor_) || !HasDescriptorMethods(descriptor_->file())) {
+ if (CheckUtf8(descriptor_)) {
printer->Print(variables_,
"$name$_.add(s);\n");
} else {