directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Felix Knecht (JIRA)" <>
Subject [jira] Created: (DIRSHARED-62) Improve antlr generated code [shared-ldap]
Date Fri, 04 Jun 2010 15:46:55 GMT
Improve antlr generated code [shared-ldap]

                 Key: DIRSHARED-62
             Project: Directory Shared
          Issue Type: Improvement
         Environment: All
            Reporter: Felix Knecht

The generated code by antlr could be improved regarding performance. Listed classes below
use the construct new Integer(...) a lot of times in their constructor. If these classes are
created many times it's an improvement to have Integer.valueOf(...). Looking at the generated
classes almost all values for new Integer are in a range of [-128,128] what matches the criterias
for more performance [1].



 Using new Integer(int) is guaranteed to always result in a new object whereas Integer.valueOf(int)
allows caching of values to be done by the compiler, class library, or JVM. Using of cached
values avoids object allocation and the code will be faster.

Values between -128 and 127 are guaranteed to have corresponding cached instances and using
valueOf is approximately 3.5 times faster than using constructor. For values outside the constant
range the performance of both styles is the same.

Unless the class must be compatible with JVMs predating Java 1.5, use either autoboxing or
the valueOf() method when creating instances of Long, Integer, Short, Character, and Byte.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message