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

chromatic at svn.parrot.org chromatic at svn.parrot.org
Fri Jun 25 03:14:05 UTC 2010


Author: chromatic
Date: Fri Jun 25 03:14:05 2010
New Revision: 47816
URL: https://trac.parrot.org/parrot/changeset/47816

Log:
[PMC] Sped up HashIterator's shift_string VTABLE.

Removing the delegation to shift_pmc() avoids creating a temporary PMC, which
speeds up the Rakudo startup benchmark by ~6.23%, and should help Rakudo run
time and anything else which performs Class introspection.

Modified:
   trunk/src/pmc/hashiterator.pmc

Modified: trunk/src/pmc/hashiterator.pmc
==============================================================================
--- trunk/src/pmc/hashiterator.pmc	Fri Jun 25 03:13:25 2010	(r47815)
+++ trunk/src/pmc/hashiterator.pmc	Fri Jun 25 03:14:05 2010	(r47816)
@@ -264,10 +264,17 @@
 */
 
     VTABLE STRING* shift_string() {
-        PMC    * const key = SELF.shift_pmc();
-        STRING * const ret = VTABLE_get_string(INTERP, key);
-        Parrot_pmc_free_temporary(INTERP, key);
-        return ret;
+        Parrot_HashIterator_attributes * const attrs =
+                PARROT_HASHITERATOR(SELF);
+        HashBucket                     * const bucket = attrs->bucket;
+
+        if (!attrs->parrot_hash || !attrs->bucket)
+            return CONST_STRING(INTERP, "");
+
+        /* Move to next bucket */
+        advance_to_next(INTERP, SELF);
+
+        return hash_key_to_string(INTERP, attrs->parrot_hash, bucket->key);
     }
 
 }


More information about the parrot-commits mailing list