string.c (index,rindex) use single byte version for ASCII strings.

This commit is contained in:
Yukihiro "Matz" Matsumoto
2022-05-21 08:51:11 +09:00
parent ac79849fde
commit 54bbc062fb
+8
View File
@@ -1789,6 +1789,10 @@ mrb_str_byteindex_m(mrb_state *mrb, mrb_value str)
static mrb_value
mrb_str_index_m(mrb_state *mrb, mrb_value str)
{
if (RSTR_ASCII_P(mrb_str_ptr(str))) {
return mrb_str_byteindex_m(mrb, str);
}
mrb_value sub;
mrb_int pos;
@@ -2056,6 +2060,10 @@ mrb_str_byterindex_m(mrb_state *mrb, mrb_value str)
static mrb_value
mrb_str_rindex_m(mrb_state *mrb, mrb_value str)
{
if (RSTR_ASCII_P(mrb_str_ptr(str))) {
return mrb_str_byterindex_m(mrb, str);
}
mrb_value sub;
mrb_int pos;
mrb_int len = RSTRING_CHAR_LEN(str);