Author: mrglavas
Date: Thu Jul 25 18:03:43 2013
New Revision: 1507079

URL: http://svn.apache.org/r1507079
Log:
Performance: Use array doubling in append(char[],int,int) for resizing the 
array. This was already being done in the other append() methods.

Modified:
    xerces/java/trunk/src/org/apache/xerces/util/XMLStringBuffer.java

Modified: xerces/java/trunk/src/org/apache/xerces/util/XMLStringBuffer.java
URL: 
http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/util/XMLStringBuffer.java?rev=1507079&r1=1507078&r2=1507079&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/util/XMLStringBuffer.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/util/XMLStringBuffer.java Thu Jul 
25 18:03:43 2013
@@ -130,9 +130,10 @@ public class XMLStringBuffer
     public void append(String s) {
         int length = s.length();
         if (this.length + length > this.ch.length) {
-            int newLength = this.ch.length*2;
-            if (newLength < this.length + length + DEFAULT_SIZE)
+            int newLength = this.ch.length * 2;
+            if (newLength < this.length + length + DEFAULT_SIZE) {
                 newLength = this.ch.length + length + DEFAULT_SIZE;
+            }
             char[] newch = new char[newLength];            
             System.arraycopy(this.ch, 0, newch, 0, this.length);
             this.ch = newch;
@@ -150,7 +151,11 @@ public class XMLStringBuffer
      */
     public void append(char[] ch, int offset, int length) {
         if (this.length + length > this.ch.length) {
-            char[] newch = new char[this.ch.length + length + DEFAULT_SIZE];
+            int newLength = this.ch.length * 2;
+            if (newLength < this.length + length + DEFAULT_SIZE) {
+                newLength = this.ch.length + length + DEFAULT_SIZE;
+            }
+            char[] newch = new char[newLength];
             System.arraycopy(this.ch, 0, newch, 0, this.length);
             this.ch = newch;
         }



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to