aboutsummaryrefslogtreecommitdiff
path: root/gen
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-05-03 17:45:08 +0200
committerThomas Voss <mail@thomasvoss.com> 2024-05-03 17:45:08 +0200
commit50093cd4fe4461c657e9133113016db1124904d9 (patch)
tree2150a2c9941e75201f559c3e624f14204e6cd122 /gen
parent17e104138e78cceb67128a3f8abd378133e993e8 (diff)
Don’t use binary search
Diffstat (limited to 'gen')
-rwxr-xr-xgen/prop/na112
1 files changed, 3 insertions, 9 deletions
diff --git a/gen/prop/na1 b/gen/prop/na1
index 776bf11..c01ee60 100755
--- a/gen/prop/na1
+++ b/gen/prop/na1
@@ -10,7 +10,6 @@ BEGIN {
print "/* This file is autogenerated by gen/prop/na1; DO NOT EDIT. */"
print ""
- print "#include \"_bsearch.h\""
print "#include \"macros.h\""
print "#include \"rune.h\""
print "#include \"unicode/prop.h\""
@@ -18,27 +17,22 @@ BEGIN {
print "#define _(...) \\"
print "\t{(const char8_t []){__VA_ARGS__}, sizeof((const char8_t []){__VA_ARGS__})}"
print ""
- print "static const struct {"
- print "\trune k;"
- print "\tstruct u8view v;"
- print "} lookup[] = {"
+ print "static const struct u8view lookup[] = {"
}
length($11) > 0 {
gsub(/./, "\x27&\x27, ", $11)
sub(/, $/, "", $11)
- printf "\t{RUNE_C(0x%06X), _(%s)},\n", strtonum("0X" $1), $11
+ printf "\t[RUNE_C(0x%06X)] = _(%s),\n", strtonum("0X" $1), $11
}
END {
print "};"
print ""
- print "_MLIB_DEFINE_BSEARCH_KV(struct u8view, lookup, (struct u8view){})"
- print ""
print "struct u8view"
print "uprop_get_na1(rune ch)"
print "{"
- print "\treturn mlib_lookup_kv(ch);"
+ print "\treturn ch < lengthof(lookup) ? lookup[ch] : (struct u8view){};"
print "}"
}
' data/UnicodeData