diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-12-03 13:18:30 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-12-03 13:18:30 +0000 |
commit | 6f2efe84fb6169a03ed191606935a40640d6764c (patch) | |
tree | c32c3b4d48daeafb526c4e8d37fe0e9870956129 /range.c | |
parent | c7159e81fc0d70b67358deaa39d21babbc3d89e7 (diff) | |
download | ruby-6f2efe84fb6169a03ed191606935a40640d6764c.tar.gz |
hash.c: detect recursion for all
* hash.c (rb_hash): detect recursion for all `hash' methods. each
`hash' methods no longer need to use rb_exec_recursive().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43980 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'range.c')
-rw-r--r-- | range.c | 32 |
1 files changed, 12 insertions, 20 deletions
@@ -243,25 +243,6 @@ range_eql(VALUE range, VALUE obj) return rb_exec_recursive_paired(recursive_eql, range, obj, obj); } -static VALUE -recursive_hash(VALUE range, VALUE dummy, int recur) -{ - st_index_t hash = EXCL(range); - VALUE v; - - hash = rb_hash_start(hash); - if (!recur) { - v = rb_hash(RANGE_BEG(range)); - hash = rb_hash_uint(hash, NUM2LONG(v)); - v = rb_hash(RANGE_END(range)); - hash = rb_hash_uint(hash, NUM2LONG(v)); - } - hash = rb_hash_uint(hash, EXCL(range) << 24); - hash = rb_hash_end(hash); - - return LONG2FIX(hash); -} - /* * call-seq: * rng.hash -> fixnum @@ -274,7 +255,18 @@ recursive_hash(VALUE range, VALUE dummy, int recur) static VALUE range_hash(VALUE range) { - return rb_exec_recursive_paired(recursive_hash, range, range, 0); + st_index_t hash = EXCL(range); + VALUE v; + + hash = rb_hash_start(hash); + v = rb_hash(RANGE_BEG(range)); + hash = rb_hash_uint(hash, NUM2LONG(v)); + v = rb_hash(RANGE_END(range)); + hash = rb_hash_uint(hash, NUM2LONG(v)); + hash = rb_hash_uint(hash, EXCL(range) << 24); + hash = rb_hash_end(hash); + + return LONG2FIX(hash); } static void |