rb_str_update: 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:
parent
d49924ed81
commit
0358846f8c
Notes:
git
2020-06-29 11:06:48 +09:00
6
string.c
6
string.c
@ -4729,14 +4729,10 @@ rb_str_update(VALUE str, long beg, long len, VALUE val)
|
||||
enc = rb_enc_check(str, val);
|
||||
slen = str_strlen(str, enc); /* rb_enc_check */
|
||||
|
||||
if (slen < beg) {
|
||||
out_of_range:
|
||||
if ((slen < beg) || ((beg < 0) && (beg + slen < 0))) {
|
||||
rb_raise(rb_eIndexError, "index %ld out of string", beg);
|
||||
}
|
||||
if (beg < 0) {
|
||||
if (beg + slen < 0) {
|
||||
goto out_of_range;
|
||||
}
|
||||
beg += slen;
|
||||
}
|
||||
assert(beg >= 0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user