From: Abhinav Gupta <mail@abhinavg.net>
Date: Mon, 17 Oct 2011 20:23:48 +0000 (+0000)
Subject: ICU-8854 Inefficient use of number constructors. Use valueOf instead.
X-Git-Tag: milestone-59-0-1~4409
X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7a58e117d9b9205d461224b92c2f729c6e951fe6;p=icu

ICU-8854 Inefficient use of number constructors. Use valueOf instead.

X-SVN-Rev: 30836
---

diff --git a/icu4j/main/classes/core/src/com/ibm/icu/text/DecimalFormat.java b/icu4j/main/classes/core/src/com/ibm/icu/text/DecimalFormat.java
index 3dbe12aa14d..b6c25c3eac9 100644
--- a/icu4j/main/classes/core/src/com/ibm/icu/text/DecimalFormat.java
+++ b/icu4j/main/classes/core/src/com/ibm/icu/text/DecimalFormat.java
@@ -1756,7 +1756,7 @@ public class DecimalFormat extends NumberFormat {
                             l = -l;
                         }
                     }
-                    n = new Long(l);
+                    n = Long.valueOf(l);
                 } else {
                     BigInteger big = digitList.getBigInteger(status[STATUS_POSITIVE]);
                     n = (big.bitLength() < 64) ? (Number) Long.valueOf(big.longValue()) : (Number) big;
diff --git a/icu4j/main/classes/core/src/com/ibm/icu/text/NFRule.java b/icu4j/main/classes/core/src/com/ibm/icu/text/NFRule.java
index ba910e2227e..027db7920af 100644
--- a/icu4j/main/classes/core/src/com/ibm/icu/text/NFRule.java
+++ b/icu4j/main/classes/core/src/com/ibm/icu/text/NFRule.java
@@ -748,7 +748,7 @@ final class NFRule {
         if (pp.getIndex() == 0 && sub1.getPos() != 0) {
             // commented out because ParsePosition doesn't have error index in 1.1.x
             //                parsePosition.setErrorIndex(pp.getErrorIndex());
-            return new Long(0);
+            return Long.valueOf(0);
         }
 
         // this is the fun part.  The basic guts of the rule-matching
@@ -993,7 +993,7 @@ final class NFRule {
             // if we make it here, this was an unsuccessful match, and we
             // leave pp unchanged and return 0
             pp.setIndex(0);
-            return new Long(0);
+            return Long.valueOf(0);
 
             // if "delimiter" is empty, or consists only of ignorable characters
             // (i.e., is semantically empty), thwe we obviously can't search
diff --git a/icu4j/main/classes/core/src/com/ibm/icu/text/RuleBasedNumberFormat.java b/icu4j/main/classes/core/src/com/ibm/icu/text/RuleBasedNumberFormat.java
index c5ce33886bc..2eed61c9305 100644
--- a/icu4j/main/classes/core/src/com/ibm/icu/text/RuleBasedNumberFormat.java
+++ b/icu4j/main/classes/core/src/com/ibm/icu/text/RuleBasedNumberFormat.java
@@ -1183,7 +1183,7 @@ public class RuleBasedNumberFormat extends NumberFormat {
         //TODO: We need a real fix.  See #6895 / #6896
         if (noParse) {
             // skip parsing
-            return new Long(0);
+            return Long.valueOf(0);
         }
 
         // parsePosition tells us where to start parsing.  We copy the
diff --git a/icu4j/main/classes/core/src/com/ibm/icu/text/TimeUnitFormat.java b/icu4j/main/classes/core/src/com/ibm/icu/text/TimeUnitFormat.java
index 7ea43a60b99..2e6f06138cf 100644
--- a/icu4j/main/classes/core/src/com/ibm/icu/text/TimeUnitFormat.java
+++ b/icu4j/main/classes/core/src/com/ibm/icu/text/TimeUnitFormat.java
@@ -290,11 +290,11 @@ public class TimeUnitFormat extends MeasureFormat {
         if (resultNumber == null && longestParseDistance != 0) {
             // set the number using plurrual count
             if ( countOfLongestMatch.equals("zero") ) {
-                resultNumber = new Integer(0);
+                resultNumber = Integer.valueOf(0);
             } else if ( countOfLongestMatch.equals("one") ) {
-                resultNumber = new Integer(1);
+                resultNumber = Integer.valueOf(1);
             } else if ( countOfLongestMatch.equals("two") ) {
-                resultNumber = new Integer(2);
+                resultNumber = Integer.valueOf(2);
             } else {
                 // should not happen.
                 // TODO: how to handle?