[svn:parrot] r42596 - trunk/src/pmc
chromatic at svn.parrot.org
chromatic at svn.parrot.org
Fri Nov 20 03:10:45 UTC 2009
Author: chromatic
Date: Fri Nov 20 03:10:44 2009
New Revision: 42596
URL: https://trac.parrot.org/parrot/changeset/42596
Log:
[PMC] Added checks for the most likely key and value types in Hash's
get_pmc_keyed_str() VTABLE, in the theory that avoiding the overhead of
function calls for hot paths will be significant. This speeds up NQP-rx's
Actions.pm benchmark by 3.844%.
Modified:
trunk/src/pmc/hash.pmc
Modified: trunk/src/pmc/hash.pmc
==============================================================================
--- trunk/src/pmc/hash.pmc Fri Nov 20 02:49:02 2009 (r42595)
+++ trunk/src/pmc/hash.pmc Fri Nov 20 03:10:44 2009 (r42596)
@@ -670,14 +670,26 @@
*/
VTABLE PMC *get_pmc_keyed_str(STRING *key) {
- const Hash * const hash = (Hash *)SELF.get_pointer();
- HashBucket * const b = parrot_hash_get_bucket(INTERP, hash,
+ const Hash *hash;
+ HashBucket *b = NULL;
+
+ GET_ATTR_hash(interp, SELF, hash);
+
+ /* special case the most key type, for speed */
+ if (hash->key_type == Hash_key_type_STRING)
+ b = parrot_hash_get_bucket(interp, hash, key);
+ else
+ b = parrot_hash_get_bucket(INTERP, hash,
hash_key_from_string(INTERP, hash, key));
if (!b)
return PMCNULL;
- return hash_value_to_pmc(INTERP, hash, b->value);
+ /* special case the most likely value type, for speed */
+ if (hash->entry_type == enum_type_PMC)
+ return (PMC *)b->value;
+ else
+ return hash_value_to_pmc(INTERP, hash, b->value);
}
VTABLE PMC *get_pmc_keyed_int(INTVAL key) {
More information about the parrot-commits
mailing list