[svn:parrot] r46179 - branches/codestring/src/pmc

coke at svn.parrot.org coke at svn.parrot.org
Fri Apr 30 06:21:23 UTC 2010


Author: coke
Date: Fri Apr 30 06:21:23 2010
New Revision: 46179
URL: https://trac.parrot.org/parrot/changeset/46179

Log:
When trying to shrink an array, forget about our previous contents.

(This doesn't seem to help with the # of ACTIVE_BUFFERS issue, but
it does seem correct.)

Modified:
   branches/codestring/src/pmc/resizablestringarray.pmc

Modified: branches/codestring/src/pmc/resizablestringarray.pmc
==============================================================================
--- branches/codestring/src/pmc/resizablestringarray.pmc	Fri Apr 30 06:03:25 2010	(r46178)
+++ branches/codestring/src/pmc/resizablestringarray.pmc	Fri Apr 30 06:21:23 2010	(r46179)
@@ -220,12 +220,25 @@
         }
         else if (new_size <= resize_threshold) {
             /* zero out anything that was previously allocated
-             * if we're growing the array */
-            INTVAL old_size;
+             * if we're growing or shrinking the array */
+            INTVAL old_size, min, max;
             GET_ATTR_size(interp, SELF, old_size);
+
             if (new_size > old_size) {
+                min = new_size;
+                max = old_size;
+            }
+            else if (new_size < old_size) {
+                min = new_size;
+                max = old_size;
+            }
+            else {
+                return;
+            }
+
+            {
                 INTVAL i;
-                for (i = old_size; i < new_size; i++)
+                for (i = min; i < max; i++)
                     str_array[i] = NULL;
             }
 


More information about the parrot-commits mailing list