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

cotto at svn.parrot.org cotto at svn.parrot.org
Thu Apr 9 19:20:56 UTC 2009


Author: cotto
Date: Thu Apr  9 19:20:55 2009
New Revision: 37998
URL: https://trac.parrot.org/parrot/changeset/37998

Log:
[PMC] use VTABLE w/switch instead of MULTI for Integer's is_equal

Modified:
   trunk/src/pmc/array.pmc
   trunk/src/pmc/integer.pmc

Modified: trunk/src/pmc/array.pmc
==============================================================================
--- trunk/src/pmc/array.pmc	Thu Apr  9 17:53:30 2009	(r37997)
+++ trunk/src/pmc/array.pmc	Thu Apr  9 19:20:55 2009	(r37998)
@@ -1156,9 +1156,7 @@
             PMC * const item2 = VTABLE_get_pmc_keyed_int(INTERP, value, j);
 
             if (item1 != item2) {
-                INTVAL result;
-                Parrot_mmd_multi_dispatch_from_c_args(INTERP, "is_equal",
-                    "PP->I", item1, item2, &result);
+                INTVAL result = VTABLE_is_equal(INTERP, item1, item2);
                 if (!result)
                     return 0;
             }

Modified: trunk/src/pmc/integer.pmc
==============================================================================
--- trunk/src/pmc/integer.pmc	Thu Apr  9 17:53:30 2009	(r37997)
+++ trunk/src/pmc/integer.pmc	Thu Apr  9 19:20:55 2009	(r37998)
@@ -1149,16 +1149,20 @@
 
 */
 
-    MULTI INTVAL is_equal(BigInt value) {
-        PMC * const temp = pmc_new(INTERP, enum_class_BigInt);
-        VTABLE_set_integer_native(INTERP, temp, SELF.get_integer());
-        return Parrot_BigInt_multi_is_equal_BigInt(INTERP, temp, value);
-    }
-
+    VTABLE INTVAL is_equal(PMC *value) {
+        PMC *temp;
 
-    MULTI INTVAL is_equal(DEFAULT value) {
-        return (VTABLE_get_integer(INTERP, SELF)
-            ==  VTABLE_get_integer(INTERP, value));
+        switch (value->vtable->base_type) {
+            case enum_class_BigInt:
+                temp = pmc_new(INTERP, enum_class_BigInt);
+                VTABLE_set_integer_native(INTERP, temp, SELF.get_integer());
+                return Parrot_BigInt_multi_is_equal_BigInt(INTERP, temp, value);
+                break;
+            default:
+                return (VTABLE_get_integer(INTERP, SELF)
+                    ==  VTABLE_get_integer(INTERP, value));
+                break;
+        }
     }
 
 


More information about the parrot-commits mailing list