aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrian Duff <bduff@google.com>2015-03-20 11:53:33 -0700
committerJeff Davidson <jpd@google.com>2015-04-06 15:41:44 -0700
commit2eadf946678a8a8d3cd56188454ab106b8dc5a39 (patch)
treec24277c76d73de8c6bcd8b8d8d8d2197dc96ee0c /src
parent001035d84dec844eac16037ac512ad9d35023ac9 (diff)
downloadexternal_protobuf-2eadf946678a8a8d3cd56188454ab106b8dc5a39.zip
external_protobuf-2eadf946678a8a8d3cd56188454ab106b8dc5a39.tar.gz
external_protobuf-2eadf946678a8a8d3cd56188454ab106b8dc5a39.tar.bz2
Inline unknownFieldData{Equals,HashCode} to generated code.
It turns out dex (apparently) was inlining these protected final methods from ExtendableMessageNano into every message class. Removing these methods from the base class and inlining their code reduces the method count by 2 methods / message when the store_unknown_fields option is on. Change-Id: I0aa09f2016d39939c4c8b8219601793b8fab301f
Diffstat (limited to 'src')
-rw-r--r--src/google/protobuf/compiler/javanano/javanano_message.cc10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/google/protobuf/compiler/javanano/javanano_message.cc b/src/google/protobuf/compiler/javanano/javanano_message.cc
index dd6ef91..758c9e8 100644
--- a/src/google/protobuf/compiler/javanano/javanano_message.cc
+++ b/src/google/protobuf/compiler/javanano/javanano_message.cc
@@ -563,7 +563,11 @@ void MessageGenerator::GenerateEquals(io::Printer* printer) {
if (params_.store_unknown_fields()) {
printer->Print(
- "return unknownFieldDataEquals(other);\n");
+ "if (unknownFieldData == null || unknownFieldData.isEmpty()) {\n"
+ " return other.unknownFieldData == null || other.unknownFieldData.isEmpty();\n"
+ "} else {\n"
+ " return unknownFieldData.equals(other.unknownFieldData);\n"
+ "}");
} else {
printer->Print(
"return true;\n");
@@ -593,7 +597,9 @@ void MessageGenerator::GenerateHashCode(io::Printer* printer) {
if (params_.store_unknown_fields()) {
printer->Print(
- "result = 31 * result + unknownFieldDataHashCode();\n");
+ "result = 31 * result + \n"
+ " (unknownFieldData == null || unknownFieldData.isEmpty() ? 0 : \n"
+ " unknownFieldData.hashCode());\n");
}
printer->Print("return result;\n");