directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Emmanuel Lecharny (JIRA)" <>
Subject [jira] Resolved: (DIRSHARED-62) Improve antlr generated code [shared-ldap]
Date Sat, 04 Sep 2010 16:25:32 GMT


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:
>             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/
> /shared-ldap/target/generated-sources/antlr/org/apache/directory/shared/ldap/aci/
> /shared-ldap/target/generated-sources/antlr/org/apache/directory/shared/ldap/subtree/
> /shared-ldap/target/generated-sources/antlr/org/apache/directory/shared/ldap/subtree/
> /shared-ldap/target/generated-sources/antlr/org/apache/directory/shared/ldap/trigger/
> [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