ruby-changes:61999
From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Mon, 29 Jun 2020 11:06:58 +0900 (JST)
Subject: [ruby-changes:61999] 0e4ee71546 (master): rb_io_each_codepoint: do not goto into a branch
https://git.ruby-lang.org/ruby.git/commit/?id=0e4ee71546 From 0e4ee71546665744a3c658bc708738b4e01d39ce 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:23:16 +0900 Subject: rb_io_each_codepoint: 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 34e8736..3e0ada4 100644 --- a/io.c +++ b/io.c @@ -4173,8 +4173,7 @@ rb_io_each_codepoint(VALUE io) https://github.com/ruby/ruby/blob/trunk/io.c#L4173 rb_yield(UINT2NUM(c)); } else if (MBCLEN_INVALID_P(r)) { - invalid: - rb_raise(rb_eArgError, "invalid byte sequence in %s", rb_enc_name(enc)); + goto invalid; } else if (MBCLEN_NEEDMORE_P(r)) { char cbuf[8], *p = cbuf; @@ -4197,6 +4196,9 @@ rb_io_each_codepoint(VALUE io) https://github.com/ruby/ruby/blob/trunk/io.c#L4196 } } return io; + + invalid: + rb_raise(rb_eArgError, "invalid byte sequence in %s", rb_enc_name(enc)); } /* -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/