ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r703146 - /ant/core/trunk/src/main/org/apache/tools/bzip2/CBZip2OutputStream.java
Date Thu, 09 Oct 2008 12:00:46 GMT
Author: bodewig
Date: Thu Oct  9 05:00:45 2008
New Revision: 703146

URL: http://svn.apache.org/viewvc?rev=703146&view=rev
Log:
re-use a pre-allocated stack.  PR 45960.

Modified:
    ant/core/trunk/src/main/org/apache/tools/bzip2/CBZip2OutputStream.java

Modified: ant/core/trunk/src/main/org/apache/tools/bzip2/CBZip2OutputStream.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/bzip2/CBZip2OutputStream.java?rev=703146&r1=703145&r2=703146&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/bzip2/CBZip2OutputStream.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/bzip2/CBZip2OutputStream.java Thu Oct  9 05:00:45
2008
@@ -999,13 +999,9 @@
         int dd;
     }
 
-    private void qSort3(int loSt, int hiSt, int dSt) {
+    private void qSort3(int loSt, int hiSt, int dSt, StackElem[] stack) {
         int unLo, unHi, ltLo, gtHi, med, n, m;
         int sp, lo, hi, d;
-        StackElem[] stack = new StackElem[QSORT_STACK_SIZE];
-        for (int count = 0; count < QSORT_STACK_SIZE; count++) {
-            stack[count] = new StackElem();
-        }
 
         sp = 0;
 
@@ -1228,6 +1224,11 @@
                 } while (h != 1);
             }
 
+            StackElem[] stack = new StackElem[QSORT_STACK_SIZE];
+            for (int count = 0; count < QSORT_STACK_SIZE; count++) {
+                stack[count] = new StackElem();
+            }
+
             /*
               The main sorting loop.
             */
@@ -1251,7 +1252,7 @@
                         int lo = ftab[sb] & CLEARMASK;
                         int hi = (ftab[sb + 1] & CLEARMASK) - 1;
                         if (hi > lo) {
-                            qSort3(lo, hi, 2);
+                            qSort3(lo, hi, 2, stack);
                             numQSorted += (hi - lo + 1);
                             if (workDone > workLimit && firstAttempt) {
                                 return;



Mime
View raw message