You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by mr...@apache.org on 2013/07/25 20:04:15 UTC

svn commit: r1507080 - /xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/util/XMLStringBuffer.java

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: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org