directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fel...@apache.org
Subject svn commit: r945826 - in /directory/shared/trunk/ldap/src: main/antlr/schema.g main/java/org/apache/directory/shared/ldap/util/ArrayUtils.java test/java/org/apache/directory/shared/ldap/schema/syntax/parser/DITStructureRuleDescriptionSchemaParserTest.java
Date Tue, 18 May 2010 19:04:03 GMT
Author: felixk
Date: Tue May 18 19:04:02 2010
New Revision: 945826

URL: http://svn.apache.org/viewvc?rev=945826&view=rev
Log:
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. 

Modified:
    directory/shared/trunk/ldap/src/main/antlr/schema.g
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/ArrayUtils.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/DITStructureRuleDescriptionSchemaParserTest.java

Modified: directory/shared/trunk/ldap/src/main/antlr/schema.g
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/antlr/schema.g?rev=945826&r1=945825&r2=945826&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/antlr/schema.g (original)
+++ directory/shared/trunk/ldap/src/main/antlr/schema.g Tue May 18 19:04:02 2010
@@ -233,7 +233,7 @@ options    {
             {
                 throw new SemanticException( element + " appears twice.", token.getFilename(),
token.getLine() , token.getColumn() );
             }
-            elementMap.put(element, new Integer(1));
+            elementMap.put(element, Integer.valueOf(1));
         }
         boolean contains(String element) 
         {

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/ArrayUtils.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/ArrayUtils.java?rev=945826&r1=945825&r2=945826&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/ArrayUtils.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/ArrayUtils.java
Tue May 18 19:04:02 2010
@@ -3274,7 +3274,7 @@ public class ArrayUtils
         final Long[] result = new Long[array.length];
         for ( int i = 0; i < array.length; i++ )
         {
-            result[i] = new Long( array[i] );
+            result[i] = Long.valueOf( array[i] );
         }
         return result;
     }
@@ -3381,7 +3381,7 @@ public class ArrayUtils
         final Integer[] result = new Integer[array.length];
         for ( int i = 0; i < array.length; i++ )
         {
-            result[i] = new Integer( array[i] );
+            result[i] = Integer.valueOf( array[i] );
         }
         return result;
     }
@@ -3488,7 +3488,7 @@ public class ArrayUtils
         final Short[] result = new Short[array.length];
         for ( int i = 0; i < array.length; i++ )
         {
-            result[i] = new Short( array[i] );
+            result[i] = Short.valueOf( array[i] );
         }
         return result;
     }
@@ -3595,7 +3595,7 @@ public class ArrayUtils
         final Byte[] result = new Byte[array.length];
         for ( int i = 0; i < array.length; i++ )
         {
-            result[i] = new Byte( array[i] );
+            result[i] = Byte.valueOf( array[i] );
         }
         return result;
     }

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/DITStructureRuleDescriptionSchemaParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/DITStructureRuleDescriptionSchemaParserTest.java?rev=945826&r1=945825&r2=945826&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/DITStructureRuleDescriptionSchemaParserTest.java
(original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/DITStructureRuleDescriptionSchemaParserTest.java
Tue May 18 19:04:02 2010
@@ -290,20 +290,20 @@ public class DITStructureRuleDescription
         value = "( 1 FORM 1.1 SUP 1 )";
         ditStructureRule = parser.parseDITStructureRuleDescription( value );
         assertEquals( 1, ditStructureRule.getSuperRules().size() );
-        assertEquals( new Integer( 1 ), ditStructureRule.getSuperRules().get( 0 ) );
+        assertEquals( Integer.valueOf( 1 ), ditStructureRule.getSuperRules().get( 0 ) );
 
         // SUP single number
         value = "( 1 FORM 1.1 SUP ( 1 ) )";
         ditStructureRule = parser.parseDITStructureRuleDescription( value );
         assertEquals( 1, ditStructureRule.getSuperRules().size() );
-        assertEquals( new Integer( 1 ), ditStructureRule.getSuperRules().get( 0 ) );
+        assertEquals( Integer.valueOf( 1 ), ditStructureRule.getSuperRules().get( 0 ) );
 
         // SUP multi number
         value = "( 1 FORM 1.1 SUP(12345 67890))";
         ditStructureRule = parser.parseDITStructureRuleDescription( value );
         assertEquals( 2, ditStructureRule.getSuperRules().size() );
-        assertEquals( new Integer( 12345 ), ditStructureRule.getSuperRules().get( 0 ) );
-        assertEquals( new Integer( 67890 ), ditStructureRule.getSuperRules().get( 1 ) );
+        assertEquals( Integer.valueOf( 12345 ), ditStructureRule.getSuperRules().get( 0 )
);
+        assertEquals( Integer.valueOf( 67890 ), ditStructureRule.getSuperRules().get( 1 )
);
 
         // non-numeric not allowed
         value = "( 1 FORM 1.1 SUP test )";
@@ -367,9 +367,9 @@ public class DITStructureRuleDescription
         assertTrue( ditStructureRule.isObsolete() );
         assertEquals( "2.3.4.5.6.7.8.9.0.1", ditStructureRule.getForm() );
         assertEquals( 3, ditStructureRule.getSuperRules().size() );
-        assertEquals( new Integer( 1 ), ditStructureRule.getSuperRules().get( 0 ) );
-        assertEquals( new Integer( 1234567890 ), ditStructureRule.getSuperRules().get( 1
) );
-        assertEquals( new Integer( 5 ), ditStructureRule.getSuperRules().get( 2 ) );
+        assertEquals( Integer.valueOf( 1 ), ditStructureRule.getSuperRules().get( 0 ) );
+        assertEquals( Integer.valueOf( 1234567890 ), ditStructureRule.getSuperRules().get(
1 ) );
+        assertEquals( Integer.valueOf( 5 ), ditStructureRule.getSuperRules().get( 2 ) );
         assertEquals( 2, ditStructureRule.getExtensions().size() );
         assertNotNull( ditStructureRule.getExtensions().get( "X-TEST-a" ) );
         assertEquals( 2, ditStructureRule.getExtensions().get( "X-TEST-a" ).size() );



Mime
View raw message