reduce object creation during JSON serialization (#2576)

If a new {@code Double} instance is not required, this method
     * should generally be used in preference to the constructor
     * {@link #Double(double)}, as this method is likely to yield
     * significantly better space and time performance by caching
     * frequently requested values.
This commit is contained in:
Thad Guidry 2020-05-05 03:07:54 -05:00 committed by GitHub
parent 26232d8507
commit 15710ace17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -109,7 +109,7 @@ public class SerializationFilters {
@Override @Override
public void serialize(Double arg0, JsonGenerator gen, SerializerProvider s) public void serialize(Double arg0, JsonGenerator gen, SerializerProvider s)
throws IOException { throws IOException {
if (new Double(arg0.longValue()).equals(arg0)) { if (Double.valueOf(arg0.longValue()).equals(arg0)) {
gen.writeNumber(arg0.longValue()); gen.writeNumber(arg0.longValue());
} else { } else {
gen.writeNumber(arg0); gen.writeNumber(arg0);