ruby-changes:62001
From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Mon, 29 Jun 2020 11:07:02 +0900 (JST)
Subject: [ruby-changes:62001] 9e92292e30 (master): rb_io_modestr_fmode: do not goto into a branch
https://git.ruby-lang.org/ruby.git/commit/?id=9e92292e30 From 9e92292e307fcdb3ef8e44f942135116de6616cf 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: Mon, 15 Jun 2020 15:26:31 +0900 Subject: rb_io_modestr_fmode: 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/io.c b/io.c index 3e0ada4..36099d8 100644 --- a/io.c +++ b/io.c @@ -5541,8 +5541,7 @@ rb_io_modestr_fmode(const char *modestr) https://github.com/ruby/ruby/blob/trunk/io.c#L5541 fmode |= FMODE_WRITABLE | FMODE_APPEND | FMODE_CREATE; break; default: - error: - rb_raise(rb_eArgError, "invalid access mode %s", modestr); + goto error; } while (*m) { @@ -5576,6 +5575,9 @@ rb_io_modestr_fmode(const char *modestr) https://github.com/ruby/ruby/blob/trunk/io.c#L5575 goto error; return fmode; + + error: + rb_raise(rb_eArgError, "invalid access mode %s", modestr); } int -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/