From cf00dd9b1b8738c816bd48da8322bf27b87a70cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Sun, 10 Apr 2016 12:46:05 +0300 Subject: [PATCH] Avoid instantiating some number objects --- .../artemis/utils/json/JSONArray.java | 4 ++-- .../artemis/utils/json/JSONObject.java | 2 +- .../selector/filter/ArithmeticExpression.java | 22 +++++++++---------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/json/JSONArray.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/json/JSONArray.java index b70bd214c6..0b8fd0c9b1 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/json/JSONArray.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/json/JSONArray.java @@ -606,7 +606,7 @@ public class JSONArray { * @throws JSONException if the value is not finite. */ public JSONArray put(final double value) throws JSONException { - Double d = new Double(value); + Double d = Double.valueOf(value); JSONObject.testValidity(d); put(d); return this; @@ -701,7 +701,7 @@ public class JSONArray { * not finite. */ public JSONArray put(final int index, final double value) throws JSONException { - put(index, new Double(value)); + put(index, Double.valueOf(value)); return this; } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/json/JSONObject.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/json/JSONObject.java index c23f7ee2bc..ad9af036bd 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/json/JSONObject.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/json/JSONObject.java @@ -978,7 +978,7 @@ public class JSONObject { * @throws JSONException If the key is null or if the number is invalid. */ public JSONObject put(final String key, final double value) throws JSONException { - put(key, new Double(value)); + put(key, Double.valueOf(value)); return this; } diff --git a/artemis-selector/src/main/java/org/apache/activemq/artemis/selector/filter/ArithmeticExpression.java b/artemis-selector/src/main/java/org/apache/activemq/artemis/selector/filter/ArithmeticExpression.java index 7ce277bd1d..3cff71104e 100755 --- a/artemis-selector/src/main/java/org/apache/activemq/artemis/selector/filter/ArithmeticExpression.java +++ b/artemis-selector/src/main/java/org/apache/activemq/artemis/selector/filter/ArithmeticExpression.java @@ -120,42 +120,42 @@ public abstract class ArithmeticExpression extends BinaryExpression { protected Number plus(Number left, Number right) { switch (numberType(left, right)) { case INTEGER: - return new Integer(left.intValue() + right.intValue()); + return left.intValue() + right.intValue(); case LONG: - return new Long(left.longValue() + right.longValue()); + return left.longValue() + right.longValue(); default: - return new Double(left.doubleValue() + right.doubleValue()); + return left.doubleValue() + right.doubleValue(); } } protected Number minus(Number left, Number right) { switch (numberType(left, right)) { case INTEGER: - return new Integer(left.intValue() - right.intValue()); + return left.intValue() - right.intValue(); case LONG: - return new Long(left.longValue() - right.longValue()); + return left.longValue() - right.longValue(); default: - return new Double(left.doubleValue() - right.doubleValue()); + return left.doubleValue() - right.doubleValue(); } } protected Number multiply(Number left, Number right) { switch (numberType(left, right)) { case INTEGER: - return new Integer(left.intValue() * right.intValue()); + return left.intValue() * right.intValue(); case LONG: - return new Long(left.longValue() * right.longValue()); + return left.longValue() * right.longValue(); default: - return new Double(left.doubleValue() * right.doubleValue()); + return left.doubleValue() * right.doubleValue(); } } protected Number divide(Number left, Number right) { - return new Double(left.doubleValue() / right.doubleValue()); + return left.doubleValue() / right.doubleValue(); } protected Number mod(Number left, Number right) { - return new Double(left.doubleValue() % right.doubleValue()); + return left.doubleValue() % right.doubleValue(); } private int numberType(Number left, Number right) {