You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ko...@apache.org on 2005/07/31 06:45:08 UTC

svn commit: r226606 - /jakarta/commons/sandbox/javaflow/trunk/src/java/org/apache/commons/javaflow/bytecode/Stack.java

Author: kohsuke
Date: Sat Jul 30 21:45:04 2005
New Revision: 226606

URL: http://svn.apache.org/viewcvs?rev=226606&view=rev
Log:
modified to double the buffer size with each reallocation.

Modified:
    jakarta/commons/sandbox/javaflow/trunk/src/java/org/apache/commons/javaflow/bytecode/Stack.java

Modified: jakarta/commons/sandbox/javaflow/trunk/src/java/org/apache/commons/javaflow/bytecode/Stack.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/javaflow/trunk/src/java/org/apache/commons/javaflow/bytecode/Stack.java?rev=226606&r1=226605&r2=226606&view=diff
==============================================================================
--- jakarta/commons/sandbox/javaflow/trunk/src/java/org/apache/commons/javaflow/bytecode/Stack.java (original)
+++ jakarta/commons/sandbox/javaflow/trunk/src/java/org/apache/commons/javaflow/bytecode/Stack.java Sat Jul 30 21:45:04 2005
@@ -168,45 +168,45 @@
     public void pushDouble(double d) {
         log.debug("push double " + d + " " + toString());
 
-        dstack[dTop++] = d;
         if (dTop == dstack.length) {
-            double[] hlp = new double[dstack.length + 10];
+            double[] hlp = new double[dstack.length*2];
             System.arraycopy(dstack, 0, hlp, 0, dstack.length);
             dstack = hlp;
         }
+        dstack[dTop++] = d;
     }
 
     public void pushFloat(float f) {
         log.debug("push float " + f + " " + toString());
         
-        fstack[fTop++] = f;
         if (fTop == fstack.length) {
-            float[] hlp = new float[fstack.length + 10];
+            float[] hlp = new float[fstack.length*2];
             System.arraycopy(fstack, 0, hlp, 0, fstack.length);
             fstack = hlp;
         }
+        fstack[fTop++] = f;
     }
 
     public void pushInt(int i) {
         log.debug("push int " + i + " " + toString());
 
-        istack[iTop++] = i;
         if (iTop == istack.length) {
-            int[] hlp = new int[istack.length + 10];
+            int[] hlp = new int[istack.length*2];
             System.arraycopy(istack, 0, hlp, 0, istack.length);
             istack = hlp;
         }
+        istack[iTop++] = i;
     }
 
     public void pushLong(long l) {
         log.debug("push long " + l + " " + toString());
         
-        lstack[lTop++] = l;
         if (lTop == lstack.length) {
-            long[] hlp = new long[lstack.length + 10];
+            long[] hlp = new long[lstack.length*2];
             System.arraycopy(lstack, 0, hlp, 0, lstack.length);
             lstack = hlp;
         }
+        lstack[lTop++] = l;
     }
 
     public void pushObject(Object o) {
@@ -221,12 +221,12 @@
             log.warn("continuation is using class " + clazz + " which is not serializable");
         }
         
-        ostack[oTop++] = o;
         if (oTop == ostack.length) {
-            Object[] hlp = new Object[ostack.length + 10];
+            Object[] hlp = new Object[ostack.length*2];
             System.arraycopy(ostack, 0, hlp, 0, ostack.length);
             ostack = hlp;
         }
+        ostack[oTop++] = o;
     }
 
     public void pushReference(Object o) {
@@ -239,12 +239,12 @@
             log.warn("continuation is referencing class " + clazz + " which is not serializable");
         }
 
-        rstack[rTop++] = o;
         if (rTop == rstack.length) {
-            Object[] hlp = new Object[rstack.length + 10];
+            Object[] hlp = new Object[rstack.length*2];
             System.arraycopy(rstack, 0, hlp, 0, rstack.length);
             rstack = hlp;
         }
+        rstack[rTop++] = o;
     }
 
     private static String getClassName(final Object o) {



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org