db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r1487773 - /db/derby/code/trunk/java/engine/org/apache/derby/iapi/util/ReuseFactory.java
Date Thu, 30 May 2013 07:19:33 GMT
Author: kahatlen
Date: Thu May 30 07:19:33 2013
New Revision: 1487773

URL: http://svn.apache.org/r1487773
Log:
DERBY-6230: Use the JVM's cache of Number instances in ReuseFactory

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/util/ReuseFactory.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/util/ReuseFactory.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/util/ReuseFactory.java?rev=1487773&r1=1487772&r2=1487773&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/util/ReuseFactory.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/util/ReuseFactory.java Thu May 30
07:19:33 2013
@@ -33,91 +33,29 @@ public class ReuseFactory {
 	private ReuseFactory() {
 	}
 
-	private static final Integer[] staticInts =
-		{new Integer(0), new Integer(1), new Integer(2), new Integer(3),
-		 new Integer(4), new Integer(5), new Integer(6), new Integer(7),
-		 new Integer(8), new Integer(9), new Integer(10), new Integer(11),
-		 new Integer(12), new Integer(13), new Integer(14), new Integer(15),
-		 new Integer(16), new Integer(17), new Integer(18)};
-	private static final Integer FIFTY_TWO = new Integer(52);
-	private static final Integer TWENTY_THREE = new Integer(23);
-	private static final Integer MAXINT = new Integer(Integer.MAX_VALUE);
-	private static final Integer MINUS_ONE = new Integer(-1);
-
 	public static Integer getInteger(int i)
 	{
-		if (i >= 0 && i < staticInts.length)
-		{
-			return staticInts[i];
-		}
-		else
-		{
-			// Look for other common values
-			switch (i)
-			{
-			  case 23:
-				return TWENTY_THREE;	// precision of Int
-
-			  case 52:
-				return FIFTY_TWO;	// precision of Double
-
-			  case Integer.MAX_VALUE:
-				return MAXINT;
-
-			  case -1:
-				return MINUS_ONE;
-
-			  default:
-				return new Integer(i);
-			}
-		}
-	}
-
-	private static final Short[] staticShorts =
-		{new Short((short) 0), new Short((short) 1), new Short((short) 2),
-		 new Short((short) 3), new Short((short) 4), new Short((short) 5),
-		 new Short((short) 6), new Short((short) 7), new Short((short) 8),
-		 new Short((short) 9), new Short((short) 10)};
+        return Integer.valueOf(i);
+	}
 
 	public static Short getShort(short i)
 	{
-		if (i >= 0 && i < staticShorts.length)
-			return staticShorts[i];
-		else
-			return new Short(i);
+        return Short.valueOf(i);
 	}
 
-	private static final Byte[] staticBytes =
-		{new Byte((byte) 0), new Byte((byte) 1), new Byte((byte) 2),
-		 new Byte((byte) 3), new Byte((byte) 4), new Byte((byte) 5),
-		 new Byte((byte) 6), new Byte((byte) 7), new Byte((byte) 8),
-		 new Byte((byte) 9), new Byte((byte) 10)};
-
 	public static Byte getByte(byte i)
 	{
-		if (i >= 0 && i < staticBytes.length)
-			return staticBytes[i];
-		else
-			return new Byte(i);
+        return Byte.valueOf(i);
 	}
 
-	private static final Long[] staticLongs =
-		{new Long(0), new Long(1), new Long(2),
-		 new Long(3), new Long(4), new Long(5),
-		 new Long(6), new Long(7), new Long(8),
-		 new Long(9), new Long(10)};
-
 	public static Long getLong(long i)
 	{
-		if (i >= 0 && i < staticLongs.length)
-			return staticLongs[(int) i];
-		else
-			return new Long(i);
+        return Long.valueOf(i);
 	}
 
     public static Boolean getBoolean( boolean b)
     {
-        return b ? Boolean.TRUE : Boolean.FALSE;
+        return Boolean.valueOf(b);
     }
 
 	private static final byte[] staticZeroLenByteArray = new byte[0];



Mime
View raw message