diff options
| author | dearblue <[email protected]> | 2019-07-14 18:55:38 +0900 |
|---|---|---|
| committer | dearblue <[email protected]> | 2019-07-14 18:55:38 +0900 |
| commit | 7b260d9c2de4436d6e8b09ba4fd524782934153f (patch) | |
| tree | 99581f5f3b98279075f29a15597322ac6f144221 /src | |
| parent | a7be9f1cab2e9b09995bb388e1219784920610e7 (diff) | |
| download | mruby-7b260d9c2de4436d6e8b09ba4fd524782934153f.tar.gz mruby-7b260d9c2de4436d6e8b09ba4fd524782934153f.zip | |
Improve `utf8len()` performance with UTF-8
Diffstat (limited to 'src')
| -rw-r--r-- | src/string.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/string.c b/src/string.c index a6aa9d906..be623deda 100644 --- a/src/string.c +++ b/src/string.c @@ -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) |
