diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-12-16 13:40:02 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-12-16 13:40:02 +0000 |
commit | 6cd0d06bae4ca127f39f8c3ea458d8a8c1b30a90 (patch) | |
tree | 23a35494ca8d7979e47c6f36cd60272af314421a /hash.c | |
parent | 62c73569c286b3bbc9f1c52a2ba4e665f450e878 (diff) | |
download | ruby-6cd0d06bae4ca127f39f8c3ea458d8a8c1b30a90.tar.gz |
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
Diffstat (limited to 'hash.c')
-rw-r--r-- | hash.c | 12 |
1 files changed, 3 insertions, 9 deletions
@@ -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 |