velocity-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cbris...@apache.org
Subject svn commit: r595713 - /velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/VelocityCharStream.java
Date Fri, 16 Nov 2007 16:10:25 GMT
Author: cbrisson
Date: Fri Nov 16 08:10:24 2007
New Revision: 595713

URL: http://svn.apache.org/viewvc?rev=595713&view=rev
Log:
apply exponential buffer expansion patch https://issues.apache.org/jira/browse/VELOCITY-570

Modified:
    velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/VelocityCharStream.java

Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/VelocityCharStream.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/VelocityCharStream.java?rev=595713&r1=595712&r2=595713&view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/VelocityCharStream.java
(original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/VelocityCharStream.java
Fri Nov 16 08:10:24 2007
@@ -41,6 +41,7 @@
   /** */
     public static final boolean staticFlag = false;
   int bufsize;
+  private int nextBufExpand = 2048;
   int available;
   int tokenBegin;
   /** */
@@ -59,12 +60,12 @@
   private char[] buffer;
   private int maxNextCharInd = 0;
   private int inBuf = 0;
-
+ 
   private final void ExpandBuff(boolean wrapAround)
   {
-     char[] newbuffer = new char[bufsize + 2048];
-     int newbufline[] = new int[bufsize + 2048];
-     int newbufcolumn[] = new int[bufsize + 2048];
+     char[] newbuffer = new char[bufsize + nextBufExpand];
+     int newbufline[] = new int[bufsize + nextBufExpand];
+     int newbufcolumn[] = new int[bufsize + nextBufExpand];
 
      try
      {
@@ -105,7 +106,8 @@
      }
 
 
-     bufsize += 2048;
+     bufsize += nextBufExpand;
+     nextBufExpand *= 2;
      available = bufsize;
      tokenBegin = 0;
   }
@@ -116,7 +118,7 @@
      {
         if (available == bufsize)
         {
-           if (tokenBegin > 2048)
+           if (tokenBegin > nextBufExpand)
            {
               bufpos = maxNextCharInd = 0;
               available = tokenBegin;
@@ -128,7 +130,7 @@
         }
         else if (available > tokenBegin)
            available = bufsize;
-        else if ((tokenBegin - available) < 2048)
+        else if ((tokenBegin - available) < nextBufExpand)
            ExpandBuff(true);
         else
            available = tokenBegin;



Mime
View raw message