Speed up wcwidth_std in the common case

This commit is contained in:
Kovid Goyal 2020-08-06 17:57:57 +05:30
parent df475dfde5
commit 8f9616c230
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 2 additions and 0 deletions

View File

@ -487,6 +487,7 @@ def gen_wcwidth() -> None:
with create_header('kitty/wcwidth-std.h') as p:
p('static int\nwcwidth_std(int32_t code) {')
p('\tif (LIKELY(0x20 <= code && code <= 0x7e)) return 1;')
p('\tswitch(code) {')
non_printing = class_maps['Cc'] | class_maps['Cf'] | class_maps['Cs']

1
kitty/wcwidth-std.h generated
View File

@ -7,6 +7,7 @@ START_ALLOW_CASE_RANGE
static int
wcwidth_std(int32_t code) {
if (LIKELY(0x20 <= code && code <= 0x7e)) return 1;
switch(code) {
// Flags (26 codepoints) {{{
case 0x1f1e6 ... 0x1f1ff: