rb_str_partition: 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
e3d821a36c
commit
5f926b2b00
Notes:
git
2020-06-29 11:06:44 +09:00
6
string.c
6
string.c
@ -9939,8 +9939,7 @@ rb_str_partition(VALUE str, VALUE sep)
|
|||||||
if (RB_TYPE_P(sep, T_REGEXP)) {
|
if (RB_TYPE_P(sep, T_REGEXP)) {
|
||||||
pos = rb_reg_search(sep, str, 0, 0);
|
pos = rb_reg_search(sep, str, 0, 0);
|
||||||
if (pos < 0) {
|
if (pos < 0) {
|
||||||
failed:
|
goto failed;
|
||||||
return rb_ary_new3(3, rb_str_dup(str), str_new_empty(str), str_new_empty(str));
|
|
||||||
}
|
}
|
||||||
sep = rb_str_subpat(str, sep, INT2FIX(0));
|
sep = rb_str_subpat(str, sep, INT2FIX(0));
|
||||||
}
|
}
|
||||||
@ -9952,6 +9951,9 @@ rb_str_partition(VALUE str, VALUE sep)
|
|||||||
sep,
|
sep,
|
||||||
rb_str_subseq(str, pos+RSTRING_LEN(sep),
|
rb_str_subseq(str, pos+RSTRING_LEN(sep),
|
||||||
RSTRING_LEN(str)-pos-RSTRING_LEN(sep)));
|
RSTRING_LEN(str)-pos-RSTRING_LEN(sep)));
|
||||||
|
|
||||||
|
failed:
|
||||||
|
return rb_ary_new3(3, rb_str_dup(str), str_new_empty(str), str_new_empty(str));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user