directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fel...@apache.org
Subject svn commit: r951326 - /directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/GeneralizedTime.java
Date Fri, 04 Jun 2010 08:51:21 GMT
Author: felixk
Date: Fri Jun  4 08:51:20 2010
New Revision: 951326

URL: http://svn.apache.org/viewvc?rev=951326&view=rev
Log:
Concatenate strings using StringBuffer
"In each iteration, the String is converted to a StringBuffer/StringBuilder, appended to,
and converted back to a String. This can lead to a cost quadratic in the number of iterations,
as the growing string is recopied in each iteration."

Modified:
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/GeneralizedTime.java

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/GeneralizedTime.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/GeneralizedTime.java?rev=951326&r1=951325&r2=951326&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/GeneralizedTime.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/GeneralizedTime.java
Fri Jun  4 08:51:20 2010
@@ -599,10 +599,10 @@ public class GeneralizedTime implements 
 
         NumberFormat twoDigits = new DecimalFormat( "00" );
         NumberFormat fourDigits = new DecimalFormat( "00" );
-        String fractionFormat = "";
+        StringBuffer fractionFormat = new StringBuffer( "" );
         for ( int i = 0; i < fractionLength && i < 3; i++ )
         {
-            fractionFormat += "0";
+            fractionFormat.append( "0" );
         }
 
         StringBuilder sb = new StringBuilder();
@@ -622,7 +622,7 @@ public class GeneralizedTime implements 
                 sb.append( twoDigits.format( calendar.get( Calendar.MINUTE ) ) );
                 sb.append( twoDigits.format( calendar.get( Calendar.SECOND ) ) );
 
-                NumberFormat fractionDigits = new DecimalFormat( fractionFormat );
+                NumberFormat fractionDigits = new DecimalFormat( fractionFormat.toString()
);
                 sb.append( fractionDelimiter == FractionDelimiter.COMMA ? ',' : '.' );
                 sb.append( fractionDigits.format( calendar.get( Calendar.MILLISECOND ) )
);
                 break;



Mime
View raw message