rb_enc_cr_str_buf_cat: 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.
This commit is contained in:
卜部昌平 2020-06-17 14:59:44 +09:00
parent 31a770ac48
commit 6df790f22e
Notes: git 2020-06-29 11:06:49 +09:00

View File

@ -2975,9 +2975,7 @@ rb_enc_cr_str_buf_cat(VALUE str, const char *ptr, long len,
ptr_cr != ENC_CODERANGE_7BIT) {
str_enc = rb_enc_from_index(str_encindex);
ptr_enc = rb_enc_from_index(ptr_encindex);
incompatible:
rb_raise(rb_eEncCompatError, "incompatible character encodings: %s and %s",
rb_enc_name(str_enc), rb_enc_name(ptr_enc));
goto incompatible;
}
if (str_cr == ENC_CODERANGE_UNKNOWN) {
@ -3013,6 +3011,10 @@ rb_enc_cr_str_buf_cat(VALUE str, const char *ptr, long len,
str_buf_cat(str, ptr, len);
ENCODING_CODERANGE_SET(str, res_encindex, res_cr);
return str;
incompatible:
rb_raise(rb_eEncCompatError, "incompatible character encodings: %s and %s",
rb_enc_name(str_enc), rb_enc_name(ptr_enc));
}
VALUE