[
https://issues.apache.org/jira/browse/DIRSHARED-62?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Emmanuel Lecharny resolved DIRSHARED-62.
----------------------------------------
Resolution: Won't Fix
This code is generated. Unless we switch to Antlr 3.0 ( and even though, I'm
not sure this would fix the problem), there is nothing we can do.
> Improve antlr generated code [shared-ldap]
> ------------------------------------------
>
> Key: DIRSHARED-62
> URL: https://issues.apache.org/jira/browse/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].
> Classes:
> /shared-ldap/target/generated-sources/antlr/org/apache/directory/shared/ldap/aci/AntlrACIItemCheckerLexer.java
> /shared-ldap/target/generated-sources/antlr/org/apache/directory/shared/ldap/aci/AntlrACIItemLexer.java
> /shared-ldap/target/generated-sources/antlr/org/apache/directory/shared/ldap/subtree/AntlrSubtreeSpecificationCheckerLexer.java
> /shared-ldap/target/generated-sources/antlr/org/apache/directory/shared/ldap/subtree/AntlrSubtreeSpecificationLexer.java
> /shared-ldap/target/generated-sources/antlr/org/apache/directory/shared/ldap/trigger/AntlrTriggerSpecificationLexer.java
> [1] http://findbugs.sourceforge.net/bugDescriptions.html#DM_NUMBER_CTOR
> 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.