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

chromatic at svn.parrot.org chromatic at svn.parrot.org
Sun Mar 28 09:49:56 UTC 2010


Author: chromatic
Date: Sun Mar 28 09:49:56 2010
New Revision: 45234
URL: https://trac.parrot.org/parrot/changeset/45234

Log:
[PMC] Removed an unnecessary temporary PMC and the comcomitant delegation from
OrderedHash PMC's get_pmc_keyed_str(); the resulting optimization speeds up
Rakudo startup by 2.631%.

Modified:
   trunk/src/pmc/orderedhash.pmc

Modified: trunk/src/pmc/orderedhash.pmc
==============================================================================
--- trunk/src/pmc/orderedhash.pmc	Sun Mar 28 09:49:53 2010	(r45233)
+++ trunk/src/pmc/orderedhash.pmc	Sun Mar 28 09:49:56 2010	(r45234)
@@ -373,11 +373,11 @@
     }
 
     VTABLE PMC *get_pmc_keyed(PMC *key) {
-        PMC * item;
+        PMC *item;
+
         /* Access by integer index */
-        if ((PObj_get_FLAGS(key) & KEY_type_FLAGS) == KEY_integer_FLAG) {
+        if ((PObj_get_FLAGS(key) & KEY_type_FLAGS) == KEY_integer_FLAG)
             return SELF.get_pmc_keyed_int(VTABLE_get_integer(INTERP, key));
-        }
 
         item = VTABLE_get_pmc_keyed(INTERP, PARROT_ORDEREDHASH(SELF)->hash, key);
         if (PMC_IS_NULL(item))
@@ -386,10 +386,13 @@
     }
 
     VTABLE PMC *get_pmc_keyed_str(STRING *key) {
-        PMC * const pkey =
-            Parrot_pmc_new(interp, Parrot_get_ctx_HLL_type(interp, enum_class_String));
-        VTABLE_set_string_native(INTERP, pkey, key);
-        return STATICSELF.get_pmc_keyed(pkey);
+        PMC *item = VTABLE_get_pmc_keyed_str(INTERP,
+            PARROT_ORDEREDHASH(SELF)->hash, key);
+
+        if (PMC_IS_NULL(item))
+            return PMCNULL;
+
+        return VTABLE_get_pmc_keyed_int(INTERP, item, ORDERED_HASH_ITEM_VALUE);
     }
 /*
 


More information about the parrot-commits mailing list