mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
string.c (bytes2chars): skip calling mrb_utf8len() if possible
If (ch < 0x80) the length of the character (in bytes) should be 1, so we don't have to call mrb_utf8len().
This commit is contained in:
+2
-1
@@ -358,7 +358,8 @@ bytes2chars(mrb_value s, mrb_int bi)
|
||||
mrb_int i;
|
||||
|
||||
for (i = 0; p < pivot; i++) {
|
||||
p += mrb_utf8len(p, e);
|
||||
if ((*p & 0x80) == 0) p++;
|
||||
else p += mrb_utf8len(p, e);
|
||||
}
|
||||
if (p != pivot) return -1;
|
||||
return i;
|
||||
|
||||
Reference in New Issue
Block a user