commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gary D. Gregory (JIRA)" <j...@apache.org>
Subject [jira] [Created] (LANG-738) Use internal Java's Number caches instead creating new objects
Date Wed, 03 Aug 2011 13:54:27 GMT
Use internal Java's Number caches instead creating new objects
--------------------------------------------------------------

                 Key: LANG-738
                 URL: https://issues.apache.org/jira/browse/LANG-738
             Project: Commons Lang
          Issue Type: Improvement
          Components: lang.*
    Affects Versions: 3.0
         Environment: Apache Maven 3.0.3 (r1075438; 2011-02-28 12:31:09-0500)
Maven home: C:\Java\apache-maven-3.0.3\bin\..
Java version: 1.6.0_24, vendor: Sun Microsystems Inc.
Java home: C:\Program Files\Java\jdk1.6.0_24\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"
            Reporter: Gary D. Gregory
            Assignee: Gary D. Gregory
             Fix For: 3.0.1


Use internal Java's Number caches instead creating new objects:

- Use more efficient Integer cache: Use "Integer.valueOf(int)" instead of "new Integer(int)".
- Use more efficient Long cache: Use "Long.valueOf(int)" instead of "new Long(long)".
- Use more efficient Short cache: Use "Short.valueOf(int)" instead of "new Short(short)".

In Java version 1.6.0_24 (vendor: Sun Microsystems Inc.), Float and Double do not implement
caches, but I've made the same changes for consistency and future proofing.

- Use "Double.valueOf(int)" instead of "new Double(double)".
- Use "Float.valueOf(int)" instead of "new Float(float)".


--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message