[svn:parrot] r37266 - trunk/src/pmc

cotto at svn.parrot.org cotto at svn.parrot.org
Tue Mar 10 09:33:28 UTC 2009


Author: cotto
Date: Tue Mar 10 09:33:28 2009
New Revision: 37266
URL: https://trac.parrot.org/parrot/changeset/37266

Log:
[PMC] Remove special case code from FixedPMCArray's set_pmc.
This VTABLE function is only called ~14 times during make test, so code clarity
and encapsulation trump optimization.

Modified:
   trunk/src/pmc/fixedpmcarray.pmc

Modified: trunk/src/pmc/fixedpmcarray.pmc
==============================================================================
--- trunk/src/pmc/fixedpmcarray.pmc	Tue Mar 10 08:21:44 2009	(r37265)
+++ trunk/src/pmc/fixedpmcarray.pmc	Tue Mar 10 09:33:28 2009	(r37266)
@@ -380,7 +380,7 @@
 
     VTABLE void set_pmc(PMC *value) {
         INTVAL size;
-        INTVAL is_set_same;
+        INTVAL i;
 
         if (SELF == value)
             return;
@@ -392,26 +392,12 @@
         if (PMC_data(SELF))
             mem_sys_free(PMC_data(SELF));
 
-        /* If the value is a FixedPMCArray or a ResizablePMCArray itself, we
-         * can just copy the data directly. Otherwise, must use interface. */
-        is_set_same    = value->vtable->base_type == enum_class_FixedPMCArray ||
-                         value->vtable->base_type == enum_class_ResizablePMCArray;
-
-        size           = PMC_int_val(SELF) = is_set_same ?
-                                                PMC_int_val(value) :
-                                                VTABLE_elements(INTERP, value);
+        size           = PMC_int_val(SELF) = VTABLE_elements(INTERP, value);
         PMC_data(SELF) = mem_allocate_n_zeroed_typed(size, PMC *);
 
-        if (is_set_same) {
-            mem_sys_memcopy(PMC_data(SELF), PMC_data(value), size * sizeof (PMC *));
-        }
-        else {
-            INTVAL i;
-            for (i = 0; i < size; i++)
-                ((PMC**)PMC_data(SELF))[i] = VTABLE_get_pmc_keyed_int(INTERP, value, i);
-        }
+        for (i = 0; i < size; i++)
+            ((PMC**)PMC_data(SELF))[i] = VTABLE_get_pmc_keyed_int(INTERP, value, i);
 
-        PMC_int_val2(SELF) = size;
         PObj_custom_mark_SET(SELF);
     }
 /*


More information about the parrot-commits mailing list