summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-12-16 13:40:02 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-12-16 13:40:02 +0000
commit6cd0d06bae4ca127f39f8c3ea458d8a8c1b30a90 (patch)
tree23a35494ca8d7979e47c6f36cd60272af314421a
parent62c73569c286b3bbc9f1c52a2ba4e665f450e878 (diff)
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
-rw-r--r--hash.c12
1 files changed, 3 insertions, 9 deletions
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