diff options
author | Thomas Voss <mail@thomasvoss.com> | 2024-05-14 15:10:06 +0200 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2024-05-14 15:10:06 +0200 |
commit | a77f15c48e1ed69b3d766eff10fcfd3d2252b17a (patch) | |
tree | 8102c83edbf1d7aa4cd8eab9715e5108f8616f4e /gen/prop/nfkc_Xcf | |
parent | 587ccc983cf36fb9e00aa10ac32b58d0205aa96a (diff) |
Properly pick optimal block size
Diffstat (limited to 'gen/prop/nfkc_Xcf')
-rwxr-xr-x | gen/prop/nfkc_Xcf | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/gen/prop/nfkc_Xcf b/gen/prop/nfkc_Xcf index 58c3abc..884e035 100755 --- a/gen/prop/nfkc_Xcf +++ b/gen/prop/nfkc_Xcf @@ -45,7 +45,6 @@ def genfile(cs: list[tuple[bool, ...]], blksize: int, _type: str) -> None: #include "macros.h" #include "unicode/prop.h" -#define M(...) ((struct rview)_(__VA_ARGS__)) #define _(...) \\ {(const rune []){__VA_ARGS__}, lengthof(((const rune []){__VA_ARGS__}))} @@ -83,8 +82,12 @@ constexpr rune SENTINAL = 0x110000; struct rview uprop_get_nfkc_{_type}(rune ch) {{ + static thread_local rune hack; struct rview rv = stage2[stage1[ch / {blksize}]][ch % {blksize}]; - return rv.len == 1 && rv.p[0] == SENTINAL ? M(ch) : rv; + if (rv.len != 1 || rv.p[0] != SENTINAL) + return rv; + hack = ch; + return (struct rview){{&hack, 1}}; }}''') def main(_type: str) -> None: @@ -101,7 +104,7 @@ def main(_type: str) -> None: cs = set(Cs) sz_s1 = len(Cs) * isize(len(cs) - 1) - sz_s2 = len(cs) * bs + sz_s2 = len(cs) * bs * 16 # (rune *) + size_t sz = sz_s1 + sz_s2 if sz < smallest: |