From 6cd0d06bae4ca127f39f8c3ea458d8a8c1b30a90 Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 16 Dec 2013 13:40:02 +0000 Subject: 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 --- hash.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'hash.c') diff --git a/hash.c b/hash.c index 83c243fbf0..9daa430026 100644 --- a/hash.c +++ b/hash.c @@ -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 -- cgit v1.2.3