Unverified Commit df293c7b authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto Committed by GitHub

Merge pull request #4578 from dearblue/improve-utf8len

Improve `utf8len()` performance with UTF-8
parents 38624074 7b260d9c
......@@ -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