Commit 7b260d9c authored by dearblue's avatar dearblue

Improve `utf8len()` performance with UTF-8

parent a7be9f1c
......@@ -233,7 +233,9 @@ utf8len(const char* p, const char* e)
mrb_int len;
mrb_int i;
if ((unsigned char)*p < 0x80) return 1;
len = utf8len_codepage[(unsigned char)*p];
if (len == 1) return 1;
if (len > e - p) return 1;
for (i = 1; i < len; ++i)
if ((p[i] & 0xc0) != 0x80)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment