mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
mruby-string-ext/string.c: reduce UTF-8 table size.
This commit is contained in:
@@ -989,16 +989,10 @@ mrb_str_succ(mrb_state *mrb, mrb_value self)
|
||||
}
|
||||
|
||||
#ifdef MRB_UTF8_STRING
|
||||
static const char utf8len_codepage_zero[256] =
|
||||
static const char utf8len_table[] =
|
||||
{
|
||||
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
||||
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
||||
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
||||
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
|
||||
3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 3, 3, 4, 0
|
||||
};
|
||||
|
||||
static mrb_int
|
||||
@@ -1009,7 +1003,7 @@ utf8code(unsigned char* p, mrb_int limit)
|
||||
if (p[0] < 0x80)
|
||||
return p[0];
|
||||
|
||||
len = utf8len_codepage_zero[p[0]];
|
||||
len = utf8len_table[p[0]>>3];
|
||||
if (len <= limit && len > 1 && (p[1] & 0xc0) == 0x80) {
|
||||
if (len == 2)
|
||||
return ((p[0] & 0x1f) << 6) + (p[1] & 0x3f);
|
||||
|
||||
Reference in New Issue
Block a user