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 376db02..a7904dc 100644
--- a/compiler/cpp/src/generate/t_java_generator.cc
+++ b/compiler/cpp/src/generate/t_java_generator.cc
@@ -1690,7 +1690,7 @@
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;
}