commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nia...@apache.org
Subject svn commit: r905163 - /commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/text/StrBuilder.java
Date Mon, 01 Feb 2010 01:06:28 GMT
Author: niallp
Date: Mon Feb  1 01:06:28 2010
New Revision: 905163

URL: http://svn.apache.org/viewvc?rev=905163&view=rev
Log:
Port LANG-523 to 2.x branch - Performance improvement to StrBuilder by doubling the size of
the String in ensureCapacity. Tests indicate a hundredhold improvement in appending speed,
which seems worth the doubling of data size. 

Modified:
    commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/text/StrBuilder.java

Modified: commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/text/StrBuilder.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/text/StrBuilder.java?rev=905163&r1=905162&r2=905163&view=diff
==============================================================================
--- commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/text/StrBuilder.java
(original)
+++ commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/text/StrBuilder.java
Mon Feb  1 01:06:28 2010
@@ -231,7 +231,7 @@
     public StrBuilder ensureCapacity(int capacity) {
         if (capacity > buffer.length) {
             char[] old = buffer;
-            buffer = new char[capacity];
+            buffer = new char[capacity * 2];
             System.arraycopy(old, 0, buffer, 0, size);
         }
         return this;



Mime
View raw message