directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r688906 - /directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java
Date Mon, 25 Aug 2008 22:31:53 GMT
Author: elecharny
Date: Mon Aug 25 15:31:52 2008
New Revision: 688906

URL: http://svn.apache.org/viewvc?rev=688906&view=rev
Log:
Improved the StringTools.dumpHexPairs to avoid using a StringBuffer

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

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java?rev=688906&r1=688905&r2=688906&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java
Mon Aug 25 15:31:52 2008
@@ -1067,15 +1067,15 @@
             return "";
         }
 
-        StringBuffer sb = new StringBuffer();
+        char[] str = new char[buffer.length << 1];
 
-        for ( int i = 0; i < buffer.length; i++ )
+        for ( int i = 0, pos = 0; i < buffer.length; i++ )
         {
-            sb.append( ( char ) ( HEX_CHAR[( buffer[i] & 0x00F0 ) >> 4] ) ).append(
-                ( char ) ( HEX_CHAR[buffer[i] & 0x000F] ) );
+            str[pos++] = ( char ) ( HEX_CHAR[( buffer[i] & 0x00F0 ) >> 4] );
+            str[pos++] = ( char ) ( HEX_CHAR[buffer[i] & 0x000F] );
         }
 
-        return sb.toString();
+        return new String( str );
     }
 
     /**



Mime
View raw message