Author: mrglavas
Date: Thu Jul 25 18:04:14 2013
New Revision: 1507080

URL: http://svn.apache.org/r1507080
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/branches/xml-schema-1.1-dev/src/org/apache/xerces/util/XMLStringBuffer.java

Modified: 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/util/XMLStringBuffer.java
URL: 
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/util/XMLStringBuffer.java?rev=1507080&r1=1507079&r2=1507080&view=diff
==============================================================================
--- 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/util/XMLStringBuffer.java
 (original)
+++ 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/util/XMLStringBuffer.java
 Thu Jul 25 18:04:14 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