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

ruby-changes:61982

From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Mon, 29 Jun 2020 11:06:24 +0900 (JST)
Subject: [ruby-changes:61982] 184f0ab4c9 (master): rb_int_parse_cstr: do not goto into a branch

https://git.ruby-lang.org/ruby.git/commit/?id=184f0ab4c9

From 184f0ab4c9e56e338de5b6fa7115c38406a184d4 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: Thu, 11 Jun 2020 12:56:05 +0900
Subject: rb_int_parse_cstr: 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/bignum.c b/bignum.c
index 072662d..43eb939 100644
--- a/bignum.c
+++ b/bignum.c
@@ -4094,10 +4094,7 @@ rb_int_parse_cstr(const char *str, ssize_t len, char **endp, size_t *ndigits, https://github.com/ruby/ruby/blob/trunk/bignum.c#L4094
     } while (0)
 
     if (!str) {
-      bad:
-	if (endp) *endp = (char *)str;
-	if (ndigits) *ndigits = num_digits;
-	return z;
+        goto bad;
     }
     if (len && (flags & RB_INT_PARSE_SIGN)) {
 	while (ISSPACE(*str)) ADV(1);
@@ -4261,6 +4258,11 @@ rb_int_parse_cstr(const char *str, ssize_t len, char **endp, size_t *ndigits, https://github.com/ruby/ruby/blob/trunk/bignum.c#L4258
     }
 
     return bignorm(z);
+
+  bad:
+    if (endp) *endp = (char *)str;
+    if (ndigits) *ndigits = num_digits;
+    return z;
 }
 
 static VALUE
-- 
cgit v0.10.2


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

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