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 /array.c | |
parent | c7159e81fc0d70b67358deaa39d21babbc3d89e7 (diff) |
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 'array.c')
-rw-r--r-- | array.c | 33 |
1 files changed, 11 insertions, 22 deletions
@@ -3774,27 +3774,6 @@ rb_ary_eql(VALUE ary1, VALUE ary2) return rb_exec_recursive_paired(recursive_eql, ary1, ary2, ary2); } -static VALUE -recursive_hash(VALUE ary, VALUE dummy, int recur) -{ - long i; - st_index_t h; - VALUE n; - - h = rb_hash_start(RARRAY_LEN(ary)); - if (recur) { - h = rb_hash_uint(h, NUM2LONG(rb_hash(rb_cArray))); - } - else { - for (i=0; i<RARRAY_LEN(ary); i++) { - n = rb_hash(RARRAY_AREF(ary, i)); - h = rb_hash_uint(h, NUM2LONG(n)); - } - } - h = rb_hash_end(h); - return LONG2FIX(h); -} - /* * call-seq: * ary.hash -> fixnum @@ -3808,7 +3787,17 @@ recursive_hash(VALUE ary, VALUE dummy, int recur) static VALUE rb_ary_hash(VALUE ary) { - return rb_exec_recursive_paired(recursive_hash, ary, ary, 0); + long i; + st_index_t h; + VALUE n; + + h = rb_hash_start(RARRAY_LEN(ary)); + for (i=0; i<RARRAY_LEN(ary); i++) { + n = rb_hash(RARRAY_AREF(ary, i)); + h = rb_hash_uint(h, NUM2LONG(n)); + } + h = rb_hash_end(h); + return LONG2FIX(h); } /* |