[armedbear-cvs] r11366 - trunk/j/src/org/armedbear/lisp

Erik Huelsmann ehuelsmann at common-lisp.net
Sun Oct 26 21:06:24 UTC 2008


Author: ehuelsmann
Date: Sun Oct 26 21:06:24 2008
New Revision: 11366

Log:
Instead of new <Java type>(...), use <Java type>.valueOf(...), allowing jvm caches.

Suggested by: dmiles (on #lisp, freenode.org IRC)

Modified:
   trunk/j/src/org/armedbear/lisp/DoubleFloat.java
   trunk/j/src/org/armedbear/lisp/Fixnum.java
   trunk/j/src/org/armedbear/lisp/LispCharacter.java
   trunk/j/src/org/armedbear/lisp/SimpleString.java
   trunk/j/src/org/armedbear/lisp/SingleFloat.java

Modified: trunk/j/src/org/armedbear/lisp/DoubleFloat.java
==============================================================================
--- trunk/j/src/org/armedbear/lisp/DoubleFloat.java	(original)
+++ trunk/j/src/org/armedbear/lisp/DoubleFloat.java	Sun Oct 26 21:06:24 2008
@@ -201,14 +201,14 @@
 
     public Object javaInstance()
     {
-        return new Double(value);
+        return Double.valueOf(value);
     }
 
     public Object javaInstance(Class c)
     {
         String cn = c.getName();
         if (cn.equals("java.lang.Float") || cn.equals("float"))
-            return new Float(value);
+            return Float.valueOf((float)value);
         return javaInstance();
     }
 

Modified: trunk/j/src/org/armedbear/lisp/Fixnum.java
==============================================================================
--- trunk/j/src/org/armedbear/lisp/Fixnum.java	(original)
+++ trunk/j/src/org/armedbear/lisp/Fixnum.java	Sun Oct 26 21:06:24 2008
@@ -53,18 +53,18 @@
 
   public Object javaInstance()
   {
-    return new Integer(value);
+    return Integer.valueOf(value);
   }
 
   public Object javaInstance(Class c)
   {
     String cn = c.getName();
     if (cn.equals("java.lang.Byte") || cn.equals("byte"))
-      return new Byte(((Integer)javaInstance()).byteValue());
+      return Byte.valueOf((byte)value);
     if (cn.equals("java.lang.Short") || cn.equals("short"))
-      return new Short(((Integer)javaInstance()).shortValue());
+      return Short.valueOf((short)value);
     if (cn.equals("java.lang.Long") || cn.equals("long"))
-      return new Long(((Integer)javaInstance()).longValue());
+      return Long.valueOf((long)value);
     return javaInstance();
   }
 

Modified: trunk/j/src/org/armedbear/lisp/LispCharacter.java
==============================================================================
--- trunk/j/src/org/armedbear/lisp/LispCharacter.java	(original)
+++ trunk/j/src/org/armedbear/lisp/LispCharacter.java	Sun Oct 26 21:06:24 2008
@@ -172,7 +172,7 @@
 
   public Object javaInstance()
   {
-    return new Character(value);
+    return Character.valueOf(value);
   }
 
   public Object javaInstance(Class c)

Modified: trunk/j/src/org/armedbear/lisp/SimpleString.java
==============================================================================
--- trunk/j/src/org/armedbear/lisp/SimpleString.java	(original)
+++ trunk/j/src/org/armedbear/lisp/SimpleString.java	Sun Oct 26 21:06:24 2008
@@ -267,12 +267,12 @@
 
     public String getStringValue()
     {
-        return new String(chars);
+        return String.valueOf(chars);
     }
 
     public Object javaInstance()
     {
-        return new String(chars);
+        return String.valueOf(chars);
     }
 
     public Object javaInstance(Class c)

Modified: trunk/j/src/org/armedbear/lisp/SingleFloat.java
==============================================================================
--- trunk/j/src/org/armedbear/lisp/SingleFloat.java	(original)
+++ trunk/j/src/org/armedbear/lisp/SingleFloat.java	Sun Oct 26 21:06:24 2008
@@ -201,14 +201,14 @@
 
     public Object javaInstance()
     {
-        return new Float(value);
+        return Float.valueOf(value);
     }
 
     public Object javaInstance(Class c)
     {
         String cn = c.getName();
         if (cn.equals("java.lang.Float") || cn.equals("float"))
-            return new Float(value);
+            return Float.valueOf(value);
         return javaInstance();
     }
 




More information about the armedbear-cvs mailing list