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
This commit is contained in:
nobu 2013-12-03 13:18:30 +00:00
parent c7159e81fc
commit 6f2efe84fb
6 changed files with 54 additions and 81 deletions

32
range.c
View file

@ -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