summaryrefslogtreecommitdiff
path: root/hash.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-10-15 15:10:17 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-10-15 15:10:17 +0000
commit261661517af17df2cb8602594ab263b25c39132c (patch)
treed535e15f414f9a9c670e59ca4b02de5f510dc670 /hash.c
parentefddc4b63276e19e25fe06d4e2530aae7e1453b8 (diff)
* hash.c (rb_hash_aref): skip calling "default" method
if it is not neede for speed-up. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29511 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/hash.c b/hash.c
index 8b165735d9..0d1898313b 100644
--- a/hash.c
+++ b/hash.c
@@ -509,7 +509,14 @@ rb_hash_aref(VALUE hash, VALUE key)
st_data_t val;
if (!RHASH(hash)->ntbl || !st_lookup(RHASH(hash)->ntbl, key, &val)) {
- return rb_funcall(hash, id_default, 1, key);
+ int rb_method_basic_definition_p(VALUE klass, ID id);
+ if (!FL_TEST(hash, HASH_PROC_DEFAULT) &&
+ rb_method_basic_definition_p(CLASS_OF(hash), id_default)) {
+ return RHASH_IFNONE(hash);
+ }
+ else {
+ return rb_funcall(hash, id_default, 1, key);
+ }
}
return (VALUE)val;
}