ruby-changes:61980
From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Mon, 29 Jun 2020 11:06:23 +0900 (JST)
Subject: [ruby-changes:61980] 5a7c0dd038 (master): str2big_scan_digits: do not goto into a branch
https://git.ruby-lang.org/ruby.git/commit/?id=5a7c0dd038 From 5a7c0dd038773ada3b729df1417d4e4ad84944e3 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:53:12 +0900 Subject: str2big_scan_digits: 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 8b15518..072662d 100644 --- a/bignum.c +++ b/bignum.c @@ -3771,12 +3771,12 @@ str2big_scan_digits(const char *s, const char *str, int base, int badcheck, size https://github.com/ruby/ruby/blob/trunk/bignum.c#L3771 return TRUE; } - if (badcheck && *str == '_') goto bad; + if (badcheck && *str == '_') return FALSE; while ((c = *str++) != 0) { if (c == '_') { if (nondigit) { - if (badcheck) goto bad; + if (badcheck) return FALSE; break; } nondigit = (char) c; @@ -3791,7 +3791,7 @@ str2big_scan_digits(const char *s, const char *str, int base, int badcheck, size https://github.com/ruby/ruby/blob/trunk/bignum.c#L3791 } if (len > 0 && !--len) break; } - if (badcheck && nondigit) goto bad; + if (badcheck && nondigit) return FALSE; if (badcheck && len) { str--; while (*str && ISSPACE(*str)) { @@ -3799,7 +3799,6 @@ str2big_scan_digits(const char *s, const char *str, int base, int badcheck, size https://github.com/ruby/ruby/blob/trunk/bignum.c#L3799 if (len > 0 && !--len) break; } if (len && *str) { - bad: return FALSE; } } -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/