[前][次][番号順一覧][スレッド一覧]

ruby-changes:32167

From: nobu <ko1@a...>
Date: Mon, 16 Dec 2013 22:40:10 +0900 (JST)
Subject: [ruby-changes:32167] nobu:r44246 (trunk): hash.c: refactor loop

nobu	2013-12-16 22:40:02 +0900 (Mon, 16 Dec 2013)

  New Revision: 44246

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=44246

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

  Modified files:
    trunk/hash.c
Index: hash.c
===================================================================
--- hash.c	(revision 44245)
+++ hash.c	(revision 44246)
@@ -87,13 +87,9 @@ VALUE https://github.com/ruby/ruby/blob/trunk/hash.c#L87
 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) https://github.com/ruby/ruby/blob/trunk/hash.c#L99
                 return LONG2FIX(-(long)ul);
             return LONG2FIX((long)ul);
         }
-
-      default:
 	hval = rb_to_int(hval);
-	goto retry;
     }
+    return hval;
 }
 
 static st_index_t

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]