From: Bryan Duxbury Date: Wed, 26 Jan 2011 18:29:33 +0000 (+0000) Subject: THRIFT-998. java: Using valueOf for base types in getFieldValue X-Git-Tag: 0.7.0~206 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=d94cb081a1b304409d59c75115d68ad794e3d408;p=common%2Fthrift.git THRIFT-998. java: Using valueOf for base types in getFieldValue valueOf saves us on memory for 'small' primitive types and costs us nothing in other situations, so it's an all-around win. Patch: Takashi Yonebayashi git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1063818 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/compiler/cpp/src/generate/t_java_generator.cc b/compiler/cpp/src/generate/t_java_generator.cc index 376db026..a7904dc6 100644 --- a/compiler/cpp/src/generate/t_java_generator.cc +++ b/compiler/cpp/src/generate/t_java_generator.cc @@ -1690,7 +1690,7 @@ void t_java_generator::generate_reflection_getters(ostringstream& out, t_type* t if (type->is_base_type() && !type->is_string()) { t_base_type* base_type = (t_base_type*)type; - indent(out) << "return new " << type_name(type, true, false) << "(" << (base_type->is_bool() ? "is" : "get") << cap_name << "());" << endl << endl; + indent(out) << "return " << type_name(type, true, false) << ".valueOf(" << (base_type->is_bool() ? "is" : "get") << cap_name << "());" << endl << endl; } else { indent(out) << "return get" << cap_name << "();" << endl << endl; }