Improve unicode compile times

This commit is contained in:
bumbread 2022-06-16 20:34:46 +11:00
parent 59e70ebfc9
commit bc1c0bcc11
3 changed files with 34648 additions and 34650 deletions

File diff suppressed because it is too large Load Diff

View File

@ -38,8 +38,15 @@ with open('unicode.h', 'w') as header:
header.write('#define Zl 26\n'); header.write('#define Zl 26\n');
header.write('#define Zp 27\n'); header.write('#define Zp 27\n');
header.write('#define Zs 28\n'); header.write('#define Zs 28\n');
header.write('\n'); header.write(
header.write('#define UNI_TAB \\\n'); '''
struct _uni_elm {
wint_t code;
wint_t cat;
wint_t lower;
wint_t upper;
} uni_codepoints[] = {
''');
with open('unicode_data.txt') as file: with open('unicode_data.txt') as file:
for line in file: for line in file:
@ -52,11 +59,11 @@ with open('unicode.h', 'w') as header:
lower = code lower = code
if upper == '' or upper == '\n': if upper == '' or upper == '\n':
upper = code upper = code
header.write(' X(' + \ header.write(' {' + \
'0x' + code + ', ' + \ '0x' + code + ', ' + \
cat + ', ' + \ cat + ', ' + \
'0x' + lower + ', ' + \ '0x' + lower + ', ' + \
'0x' + upper + ')\\\n'); '0x' + upper + '},\n');
header.write('\n'); header.write('};\n\n');
header.close(); header.close();

View File

@ -5,12 +5,7 @@
#include "unicode.h" #include "unicode.h"
static inline int char_cat(wint_t wc) { static inline int char_cat(wint_t wc) {
#define X(code, cat, l, u) case code: return cat; return uni_codepoints[wc].cat;
switch(wc) {
UNI_TAB
}
#undef X
return -1;
} }
int iswctype(wint_t wc, wctype_t desc) { int iswctype(wint_t wc, wctype_t desc) {
@ -109,19 +104,9 @@ int iswxdigit(wint_t wc) {
} }
wint_t towlower(wint_t wc) { wint_t towlower(wint_t wc) {
#define X(code, cat, l, u) case code: return l; return uni_codepoints[wc].lower;
switch(wc) {
UNI_TAB
}
#undef X
return wc;
} }
wint_t towupper(wint_t wc) { wint_t towupper(wint_t wc) {
#define X(code, cat, l, u) case code: return u; return uni_codepoints[wc].upper;
switch(wc) {
UNI_TAB
}
#undef X
return wc;
} }