diff options
author | Max Cai <maxtroy@google.com> | 2013-10-11 16:41:41 +0100 |
---|---|---|
committer | Max Cai <maxtroy@google.com> | 2013-10-11 16:44:40 +0100 |
commit | 5ae438cf71487d5bc8cb5c0d0e637f976734d110 (patch) | |
tree | 688c10f285f9594d56d791d1757fc81f6c4d70ec /src/google/protobuf/compiler/javanano/javanano_message.cc | |
parent | cbb08132821cb56f4e6c5e5f8a0b32f51879782a (diff) | |
download | external_protobuf-5ae438cf71487d5bc8cb5c0d0e637f976734d110.zip external_protobuf-5ae438cf71487d5bc8cb5c0d0e637f976734d110.tar.gz external_protobuf-5ae438cf71487d5bc8cb5c0d0e637f976734d110.tar.bz2 |
Remove all field initializers and let ctor call clear().
The field initializers have basically caused the compiled <init> method
to inline the whole clear() method, which means if ProGuard is not used
or failed to inline or remove clear(), there are two big chunks of code
that do the same thing. So why not just call clear() from the ctor.
Change-Id: Ief71e2b03db2e059b3bfa98309649368089ffab0
Diffstat (limited to 'src/google/protobuf/compiler/javanano/javanano_message.cc')
-rw-r--r-- | src/google/protobuf/compiler/javanano/javanano_message.cc | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/google/protobuf/compiler/javanano/javanano_message.cc b/src/google/protobuf/compiler/javanano/javanano_message.cc index c9ea654..420405d 100644 --- a/src/google/protobuf/compiler/javanano/javanano_message.cc +++ b/src/google/protobuf/compiler/javanano/javanano_message.cc @@ -144,7 +144,9 @@ void MessageGenerator::Generate(io::Printer* printer) { printer->Indent(); printer->Print( "public static final $classname$ EMPTY_ARRAY[] = {};\n" - "public $classname$() {}\n" + "public $classname$() {\n" + " clear();\n" + "}\n" "\n", "classname", descriptor_->name()); @@ -244,7 +246,7 @@ GenerateMessageSerializationMethods(io::Printer* printer) { printer->Print( "}\n" "\n" - "private int cachedSize = -1;\n" + "private int cachedSize;\n" "@Override\n" "public int getCachedSize() {\n" " if (cachedSize < 0) {\n" |