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

ruby-changes:62073

From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Mon, 29 Jun 2020 11:08:47 +0900 (JST)
Subject: [ruby-changes:62073] 82ed66a75a (master): rb_cstr_to_dbl_raise: do not goto into a branch

https://git.ruby-lang.org/ruby.git/commit/?id=82ed66a75a

From 82ed66a75a7abbf3b6e18be962ed9c11029b6722 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?=
 <shyouhei@r...>
Date: Tue, 16 Jun 2020 11:22:04 +0900
Subject: rb_cstr_to_dbl_raise: do not goto into a branch

I'm not necessarily against every goto in general, but jumping into a
branch is definitely a bad idea.  Better refactor.

diff --git a/object.c b/object.c
index 04a41cd..fd7d02b 100644
--- a/object.c
+++ b/object.c
@@ -3530,13 +3530,7 @@ rb_cstr_to_dbl_raise(const char *p, int badcheck, int raise, int *error) https://github.com/ruby/ruby/blob/trunk/object.c#L3530
     }
     if (p == end) {
         if (badcheck) {
-          bad:
-            if (raise)
-                rb_invalid_str(q, "Float()");
-            else {
-                if (error) *error = 1;
-                return 0.0;
-            }
+            goto bad;
         }
         return d;
     }
@@ -3611,6 +3605,14 @@ rb_cstr_to_dbl_raise(const char *p, int badcheck, int raise, int *error) https://github.com/ruby/ruby/blob/trunk/object.c#L3605
         rb_raise(rb_eArgError, "Float %.*s%s out of range", w, q, ellipsis);
     }
     return d;
+
+  bad:
+    if (raise)
+        rb_invalid_str(q, "Float()");
+    else {
+        if (error) *error = 1;
+        return 0.0;
+    }
 }
 
 /*!
-- 
cgit v0.10.2


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

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