ruby-changes:62052
From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Mon, 29 Jun 2020 11:08:26 +0900 (JST)
Subject: [ruby-changes:62052] ce6be8889f (master): utc_offset_arg: do not goto into a branch
https://git.ruby-lang.org/ruby.git/commit/?id=ce6be8889f From ce6be8889f10632f8ee0a52aaf86a4a598e74af1 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: Fri, 19 Jun 2020 12:44:57 +0900 Subject: utc_offset_arg: 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/time.c b/time.c index 6d599d4..1e8f2e9 100644 --- a/time.c +++ b/time.c @@ -2079,8 +2079,7 @@ utc_offset_arg(VALUE arg) https://github.com/ruby/ruby/blob/trunk/time.c#L2079 int n = 0; char *s = RSTRING_PTR(tmp); if (!rb_enc_str_asciicompat_p(tmp)) { - invalid_utc_offset: - return Qnil; + goto invalid_utc_offset; } switch (RSTRING_LEN(tmp)) { case 1: @@ -2131,6 +2130,8 @@ utc_offset_arg(VALUE arg) https://github.com/ruby/ruby/blob/trunk/time.c#L2130 else { return num_exact(arg); } + invalid_utc_offset: + return Qnil; } static void -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/