diff options
author | 卜部昌平 <shyouhei@ruby-lang.org> | 2020-06-15 15:23:16 +0900 |
---|---|---|
committer | 卜部昌平 <shyouhei@ruby-lang.org> | 2020-06-29 11:05:41 +0900 |
commit | 0e4ee71546665744a3c658bc708738b4e01d39ce (patch) | |
tree | b6751cb9baf122d3abd64db8706228603a11be42 /io.c | |
parent | 1e8461424c10f8b22a926b2c6bc12dbf3eea4610 (diff) |
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.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/3247
Diffstat (limited to 'io.c')
-rw-r--r-- | io.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -4173,8 +4173,7 @@ rb_io_each_codepoint(VALUE io) 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) } } return io; + + invalid: + rb_raise(rb_eArgError, "invalid byte sequence in %s", rb_enc_name(enc)); } /* |