mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
string.c (bytes2chars): skip scanning if the string is ASCII only
This commit is contained in:
@@ -348,6 +348,10 @@ chars2bytes(mrb_value s, mrb_int off, mrb_int idx)
|
||||
static mrb_int
|
||||
bytes2chars(mrb_value s, mrb_int bi)
|
||||
{
|
||||
if (RSTR_ASCII_P(mrb_str_ptr(s))) {
|
||||
return bi;
|
||||
}
|
||||
|
||||
const char *p = RSTRING_PTR(s);
|
||||
const char *e = RSTRING_END(s);
|
||||
const char *pivot = p + bi;
|
||||
|
||||
Reference in New Issue
Block a user