summaryrefslogtreecommitdiff
path: root/array.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-12-03 13:18:30 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-12-03 13:18:30 +0000
commit6f2efe84fb6169a03ed191606935a40640d6764c (patch)
treec32c3b4d48daeafb526c4e8d37fe0e9870956129 /array.c
parentc7159e81fc0d70b67358deaa39d21babbc3d89e7 (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.c33
1 files changed, 11 insertions, 22 deletions
diff --git a/array.c b/array.c
index 7417a7c449..39144b25f4 100644
--- a/array.c
+++ b/array.c
@@ -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);
}
/*