diff options
author | Adam Cozzette <acozzette@google.com> | 2016-11-17 16:48:38 -0800 |
---|---|---|
committer | Adam Cozzette <acozzette@google.com> | 2016-11-17 16:59:59 -0800 |
commit | 5a76e633ea9b5adb215e93fdc11e1c0c08b3fc74 (patch) | |
tree | 0276f81f8848a05d84cd7e287b43d665e30f04e3 /src/google/protobuf/compiler/java/java_message.cc | |
parent | e28286fa05d8327fd6c5aa70cfb3be558f0932b8 (diff) |
Integrated internal changes from Google
Diffstat (limited to 'src/google/protobuf/compiler/java/java_message.cc')
-rw-r--r-- | src/google/protobuf/compiler/java/java_message.cc | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/src/google/protobuf/compiler/java/java_message.cc b/src/google/protobuf/compiler/java/java_message.cc index 68d28b05..df4db463 100644 --- a/src/google/protobuf/compiler/java/java_message.cc +++ b/src/google/protobuf/compiler/java/java_message.cc @@ -110,7 +110,7 @@ void ImmutableMessageGenerator::GenerateStaticVariables( // the outermost class in the file. This way, they will be initialized in // a deterministic order. - map<string, string> vars; + std::map<string, string> vars; vars["identifier"] = UniqueFileScopeIdentifier(descriptor_); vars["index"] = SimpleItoa(descriptor_->index()); vars["classname"] = name_resolver_->GetImmutableClassName(descriptor_); @@ -154,7 +154,7 @@ void ImmutableMessageGenerator::GenerateStaticVariables( int ImmutableMessageGenerator::GenerateStaticVariableInitializers( io::Printer* printer) { int bytecode_estimate = 0; - map<string, string> vars; + std::map<string, string> vars; vars["identifier"] = UniqueFileScopeIdentifier(descriptor_); vars["index"] = SimpleItoa(descriptor_->index()); vars["classname"] = name_resolver_->GetImmutableClassName(descriptor_); @@ -191,7 +191,7 @@ int ImmutableMessageGenerator::GenerateStaticVariableInitializers( void ImmutableMessageGenerator:: GenerateFieldAccessorTable(io::Printer* printer, int* bytecode_estimate) { - map<string, string> vars; + std::map<string, string> vars; vars["identifier"] = UniqueFileScopeIdentifier(descriptor_); if (MultipleJavaFiles(descriptor_->file(), /* immutable = */ true)) { // We can only make these package-private since the classes that use them @@ -299,7 +299,7 @@ void ImmutableMessageGenerator::GenerateInterface(io::Printer* printer) { void ImmutableMessageGenerator::Generate(io::Printer* printer) { bool is_own_file = IsOwnFile(descriptor_, /* immutable = */ true); - map<string, string> variables; + std::map<string, string> variables; variables["static"] = is_own_file ? " " : " static "; variables["classname"] = descriptor_->name(); variables["extra_interfaces"] = ExtraMessageInterfaces(descriptor_); @@ -409,7 +409,7 @@ void ImmutableMessageGenerator::Generate(io::Printer* printer) { } // oneof - map<string, string> vars; + std::map<string, string> vars; for (int i = 0; i < descriptor_->oneof_decl_count(); i++) { vars["oneof_name"] = context_->GetOneofGeneratorInfo( descriptor_->oneof_decl(i))->name; @@ -561,13 +561,12 @@ GenerateMessageSerializationMethods(io::Printer* printer) { google::protobuf::scoped_array<const FieldDescriptor * > sorted_fields( SortFieldsByNumber(descriptor_)); - vector<const Descriptor::ExtensionRange*> sorted_extensions; + std::vector<const Descriptor::ExtensionRange*> sorted_extensions; for (int i = 0; i < descriptor_->extension_range_count(); ++i) { sorted_extensions.push_back(descriptor_->extension_range(i)); } std::sort(sorted_extensions.begin(), sorted_extensions.end(), ExtensionRangeOrdering()); - printer->Print( "public void writeTo(com.google.protobuf.CodedOutputStream output)\n" " throws java.io.IOException {\n"); @@ -799,7 +798,7 @@ GenerateDescriptorMethods(io::Printer* printer) { "fileclass", name_resolver_->GetImmutableClassName(descriptor_->file()), "identifier", UniqueFileScopeIdentifier(descriptor_)); } - vector<const FieldDescriptor*> map_fields; + std::vector<const FieldDescriptor*> map_fields; for (int i = 0; i < descriptor_->field_count(); i++) { const FieldDescriptor* field = descriptor_->field(i); if (GetJavaType(field) == JAVATYPE_MESSAGE && @@ -1093,7 +1092,12 @@ GenerateEqualsAndHashCode(io::Printer* printer) { "}\n" "int hash = 41;\n"); - printer->Print("hash = (19 * hash) + getDescriptorForType().hashCode();\n"); + // If we output a getDescriptor() method, use that as it is more efficient. + if (descriptor_->options().no_standard_descriptor_accessor()) { + printer->Print("hash = (19 * hash) + getDescriptorForType().hashCode();\n"); + } else { + printer->Print("hash = (19 * hash) + getDescriptor().hashCode();\n"); + } // hashCode non-oneofs. for (int i = 0; i < descriptor_->field_count(); i++) { @@ -1254,7 +1258,7 @@ GenerateParsingConstructor(io::Printer* printer) { printer->Print( "case $tag$: {\n", - "tag", SimpleItoa(tag)); + "tag", SimpleItoa(static_cast<int32>(tag))); printer->Indent(); field_generators_.get(field).GenerateParsingCode(printer); @@ -1271,7 +1275,7 @@ GenerateParsingConstructor(io::Printer* printer) { WireFormatLite::WIRETYPE_LENGTH_DELIMITED); printer->Print( "case $tag$: {\n", - "tag", SimpleItoa(packed_tag)); + "tag", SimpleItoa(static_cast<int32>(packed_tag))); printer->Indent(); field_generators_.get(field).GenerateParsingCodeFromPacked(printer); @@ -1417,7 +1421,7 @@ void ImmutableMessageGenerator::GenerateAnyMethods(io::Printer* printer) { "}\n" "\n" "/**\n" - " * Packs a message uisng the given type URL prefix. The type URL will\n" + " * Packs a message using the given type URL prefix. The type URL will\n" " * be constructed by concatenating the message type's full name to the\n" " * prefix with an optional \"/\" separator if the prefix doesn't end\n" " * with \"/\" already.\n" |