bench: update codepoint-width

This commit is contained in:
Mitchell Hashimoto
2024-02-08 21:10:06 -08:00
parent 9755d0696e
commit f6e694bf80
2 changed files with 3 additions and 3 deletions

View File

@ -29,8 +29,6 @@ hyperfine \
"./zig-out/bin/bench-codepoint-width --mode=wcwidth${ARGS} </tmp/ghostty_bench_data" \
-n utf8proc \
"./zig-out/bin/bench-codepoint-width --mode=utf8proc${ARGS} </tmp/ghostty_bench_data" \
-n ziglyph \
"./zig-out/bin/bench-codepoint-width --mode=ziglyph${ARGS} </tmp/ghostty_bench_data" \
-n table \
"./zig-out/bin/bench-codepoint-width --mode=table${ARGS} </tmp/ghostty_bench_data" \
-n simd \

View File

@ -172,7 +172,9 @@ noinline fn benchTable(
const cp_, const consumed = d.next(c);
assert(consumed);
if (cp_) |cp| {
const width = table.get(@intCast(cp)).width;
// This is the same trick we do in terminal.zig so we
// keep it here.
const width = if (cp <= 0xFF) 1 else table.get(@intCast(cp)).width;
// Write the width to the buffer to avoid it being compiled away
buf[0] = @intCast(width);