[svn:parrot] r43960 - in branches/tt362: src/pmc t/pmc

plobsing at svn.parrot.org plobsing at svn.parrot.org
Mon Feb 15 03:02:43 UTC 2010


Author: plobsing
Date: Mon Feb 15 03:02:42 2010
New Revision: 43960
URL: https://trac.parrot.org/parrot/changeset/43960

Log:
eliminate ImageIO.id_list

slight modification to t/pmc/imageio.t. re-usability is not a feature of ImageIO, and now it isn't.

Modified:
   branches/tt362/src/pmc/imageio.pmc
   branches/tt362/t/pmc/imageio.t

Modified: branches/tt362/src/pmc/imageio.pmc
==============================================================================
--- branches/tt362/src/pmc/imageio.pmc	Mon Feb 15 02:00:27 2010	(r43959)
+++ branches/tt362/src/pmc/imageio.pmc	Mon Feb 15 03:02:42 2010	(r43960)
@@ -123,7 +123,7 @@
 PARROT_INLINE
 static PMC*
 id_list_get(PARROT_INTERP, PMC *io, UINTVAL id) {
-    return VTABLE_get_pmc_keyed_int(interp, PARROT_IMAGEIO(io)->id_list, id);
+    return VTABLE_get_pmc_keyed_int(interp, PARROT_IMAGEIO(io)->todo, id - 1);
 }
 
 PARROT_INLINE
@@ -153,10 +153,7 @@
 
             {
                 PMC * const todo    = PARROT_IMAGEIO(info)->todo;
-                PMC * const id_list = PARROT_IMAGEIO(info)->id_list;
-                VTABLE_set_pmc_keyed_int(interp, id_list, id, pmc);
-                /* remember nested aggregates depth first */
-                VTABLE_push_pmc(interp, todo, pmc);
+                VTABLE_set_pmc_keyed_int(interp, todo, id - 1, pmc);
             }
         }
         break;
@@ -210,12 +207,13 @@
 static void
 visit_loop_todo_list(PARROT_INTERP, PMC *info)
 {
-    PMC * const todo     = PARROT_IMAGEIO(info)->todo;
-    const int    thawing = PARROT_IMAGEIO(info)->what == VISIT_THAW_NORMAL;
+    INTVAL      i;
+    PMC * const todo    = PARROT_IMAGEIO(info)->todo;
+    const int   thawing = VTABLE_get_integer(interp, info) == VISIT_THAW_NORMAL;
 
     /* can't cache upper limit, visit may append items */
-    while (VTABLE_get_bool(interp, todo)) {
-        PMC *current = VTABLE_pop_pmc(interp, todo);
+    for (i = 0; i < VTABLE_elements(interp, todo); i++) {
+        PMC *current = VTABLE_get_pmc_keyed_int(interp, todo, i);
         if (!current)
             Parrot_ex_throw_from_c_args(interp, NULL, 1,
                     "NULL current PMC in visit_loop_todo_list");
@@ -233,7 +231,7 @@
 
     if (thawing) {
         /* on thawing call thawfinish for each processed PMC */
-        const INTVAL n = VTABLE_elements(interp, PARROT_IMAGEIO(info)->id_list);
+        const INTVAL n = VTABLE_elements(interp, todo);
         int          i;
 
         /*
@@ -245,7 +243,7 @@
          *      order here is likely broken.
          */
         for (i = n-1; i >= 0; --i) {
-            PMC *current = VTABLE_get_pmc_keyed_int(interp, PARROT_IMAGEIO(info)->id_list, i);
+            PMC *current = VTABLE_get_pmc_keyed_int(interp, todo, i);
             if (!PMC_IS_NULL(current))
                 VTABLE_thawfinish(interp, current, info);
         }
@@ -260,7 +258,6 @@
     ATTR PMC             *pmc_result;     /* where to thaw a new PMC */
     ATTR PMC             *seen;           /* seen hash */
     ATTR PMC             *todo;           /* todo list */
-    ATTR PMC             *id_list;        /* seen list used by thaw */
     ATTR UINTVAL          id;             /* freze ID of PMC */
     ATTR INTVAL           extra_flags;    /* concerning to extra */
     ATTR struct PackFile *pf;
@@ -289,7 +286,6 @@
         PARROT_IMAGEIO(SELF)->buffer      = NULL;
         PARROT_IMAGEIO(SELF)->todo        = pmc_new(INTERP, enum_class_ResizablePMCArray);
         PARROT_IMAGEIO(SELF)->seen        = PMCNULL;
-        PARROT_IMAGEIO(SELF)->id_list     = PMCNULL;
         PARROT_IMAGEIO(SELF)->id          = 0;
         PARROT_IMAGEIO(SELF)->extra_flags = EXTRA_IS_NULL;
         PARROT_IMAGEIO(SELF)->pf          = PackFile_new(INTERP, 0);
@@ -326,7 +322,6 @@
             Parrot_gc_mark_PObj_alive(INTERP, (PObj *)(PARROT_IMAGEIO(SELF)->buffer));
         Parrot_gc_mark_PMC_alive(INTERP, PARROT_IMAGEIO(SELF)->todo);
         Parrot_gc_mark_PMC_alive(INTERP, PARROT_IMAGEIO(SELF)->seen);
-        Parrot_gc_mark_PMC_alive(INTERP, PARROT_IMAGEIO(SELF)->id_list);
     }
 
 /*
@@ -356,7 +351,7 @@
 */
 
     VTABLE PMC *get_pmc() {
-        return VTABLE_get_pmc_keyed_int(INTERP, (PARROT_IMAGEIO(SELF))->id_list, 1);
+        return VTABLE_get_pmc_keyed_int(INTERP, (PARROT_IMAGEIO(SELF))->todo, 0);
     }
 
 /*
@@ -541,7 +536,6 @@
 
         PARROT_IMAGEIO(SELF)->what          = VISIT_THAW_NORMAL;
         PARROT_IMAGEIO(SELF)->buffer        = (Buffer *)image;
-        PARROT_IMAGEIO(SELF)->id_list       = pmc_new(INTERP, enum_class_ResizablePMCArray);
 
         PARROT_ASSERT(image->_bufstart == image->strstart);
 

Modified: branches/tt362/t/pmc/imageio.t
==============================================================================
--- branches/tt362/t/pmc/imageio.t	Mon Feb 15 02:00:27 2010	(r43959)
+++ branches/tt362/t/pmc/imageio.t	Mon Feb 15 03:02:42 2010	(r43960)
@@ -33,6 +33,7 @@
     $S1 = freeze test_pmc
     is($S0, $S1, 'freeze gives same image as ImageIO (simple)')
 
+    imageio = new ['ImageIO']
     imageio = $S0
     $P0 = deref imageio
     ok($P0, 'thawed PMC is true (simple)')
@@ -48,6 +49,7 @@
     $S1 = freeze test_pmc
     is($S0, $S1, 'freeze gives same image as ImageIO (aggregate)')
 
+    imageio = new ['ImageIO']
     imageio = $S0
     $P0 = deref imageio
     ok($P0, 'thawed PMC is true (aggregate)')


More information about the parrot-commits mailing list