1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

hash.c: refactor loop

* hash.c (rb_hash): rewrite with while instead of goto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44246 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2013-12-16 13:40:02 +00:00
parent 62c73569c2
commit 6cd0d06bae

12
hash.c
View file

@ -87,13 +87,9 @@ VALUE
rb_hash(VALUE obj)
{
VALUE hval = rb_exec_recursive_outer(hash_recursive, obj, 0);
retry:
switch (TYPE(hval)) {
case T_FIXNUM:
return hval;
case T_BIGNUM:
{
while (!FIXNUM_P(hval)) {
if (RB_TYPE_P(hval, T_BIGNUM)) {
int sign;
unsigned long ul;
sign = rb_integer_pack(hval, &ul, 1, sizeof(ul), 0,
@ -103,11 +99,9 @@ rb_hash(VALUE obj)
return LONG2FIX(-(long)ul);
return LONG2FIX((long)ul);
}
default:
hval = rb_to_int(hval);
goto retry;
}
return hval;
}
static st_index_t