Return-Path: Delivered-To: apmail-velocity-commits-archive@locus.apache.org Received: (qmail 78182 invoked from network); 16 Nov 2007 16:11:04 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 16 Nov 2007 16:11:04 -0000 Received: (qmail 31653 invoked by uid 500); 16 Nov 2007 16:10:39 -0000 Delivered-To: apmail-velocity-commits-archive@velocity.apache.org Received: (qmail 31620 invoked by uid 500); 16 Nov 2007 16:10:39 -0000 Mailing-List: contact commits-help@velocity.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@velocity.apache.org Delivered-To: mailing list commits@velocity.apache.org Received: (qmail 31581 invoked by uid 99); 16 Nov 2007 16:10:39 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 Nov 2007 08:10:39 -0800 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 Nov 2007 16:10:37 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 83A471A9832; Fri, 16 Nov 2007 08:10:25 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r595713 - /velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/VelocityCharStream.java Date: Fri, 16 Nov 2007 16:10:25 -0000 To: commits@velocity.apache.org From: cbrisson@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20071116161025.83A471A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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;