renderer: add LUT-based implementation of isSymbol (#8528)

The LUT-based lookup gives a ~20%-30% speedup over the "naive" isSymbol
implementation.

<img width="1206" height="730" alt="Screenshot From 2025-09-04 22-45-10"
src="https://github.com/user-attachments/assets/09a8ef3a-8b4b-43ba-963a-849338307251"
/>
<img width="1206" height="730" alt="Screenshot From 2025-09-04 22-41-54"
src="https://github.com/user-attachments/assets/27962a88-f99c-446d-b986-30f526239ba3"
/>

Fixes #8523
This commit is contained in:
Jeffrey C. Ollie
2025-09-05 12:04:28 -05:00
committed by GitHub
11 changed files with 296 additions and 27 deletions

View File

@@ -61,6 +61,7 @@ emit_termcap: bool = false,
emit_test_exe: bool = false,
emit_xcframework: bool = false,
emit_webdata: bool = false,
emit_unicode_table_gen: bool = false,
/// Environmental properties
env: std.process.EnvMap,
@@ -299,6 +300,12 @@ pub fn init(b: *std.Build) !Config {
"Build and install test executables with 'build'",
) orelse false;
config.emit_unicode_table_gen = b.option(
bool,
"emit-unicode-table-gen",
"Build and install executables that generate unicode tables with 'build'",
) orelse false;
config.emit_bench = b.option(
bool,
"emit-bench",

View File

@@ -31,6 +31,7 @@ pub fn init(b: *std.Build, cfg: *const Config) !SharedDeps {
.metallib = undefined,
};
try result.initTarget(b, cfg.target);
if (cfg.emit_unicode_table_gen) result.unicode_tables.install(b);
return result;
}

View File

@@ -4,14 +4,16 @@ const std = @import("std");
const Config = @import("Config.zig");
/// The exe.
exe: *std.Build.Step.Compile,
props_exe: *std.Build.Step.Compile,
symbols_exe: *std.Build.Step.Compile,
/// The output path for the unicode tables
output: std.Build.LazyPath,
props_output: std.Build.LazyPath,
symbols_output: std.Build.LazyPath,
pub fn init(b: *std.Build) !UnicodeTables {
const exe = b.addExecutable(.{
.name = "unigen",
const props_exe = b.addExecutable(.{
.name = "props-unigen",
.root_module = b.createModule(.{
.root_source_file = b.path("src/unicode/props.zig"),
.target = b.graph.host,
@@ -21,31 +23,53 @@ pub fn init(b: *std.Build) !UnicodeTables {
}),
});
const symbols_exe = b.addExecutable(.{
.name = "symbols-unigen",
.root_module = b.createModule(.{
.root_source_file = b.path("src/unicode/symbols.zig"),
.target = b.graph.host,
.strip = false,
.omit_frame_pointer = false,
.unwind_tables = .sync,
}),
});
if (b.lazyDependency("ziglyph", .{
.target = b.graph.host,
})) |ziglyph_dep| {
exe.root_module.addImport(
"ziglyph",
ziglyph_dep.module("ziglyph"),
);
inline for (&.{ props_exe, symbols_exe }) |exe| {
exe.root_module.addImport(
"ziglyph",
ziglyph_dep.module("ziglyph"),
);
}
}
const run = b.addRunArtifact(exe);
const props_run = b.addRunArtifact(props_exe);
const symbols_run = b.addRunArtifact(symbols_exe);
return .{
.exe = exe,
.output = run.captureStdOut(),
.props_exe = props_exe,
.symbols_exe = symbols_exe,
.props_output = props_run.captureStdOut(),
.symbols_output = symbols_run.captureStdOut(),
};
}
/// Add the "unicode_tables" import.
pub fn addImport(self: *const UnicodeTables, step: *std.Build.Step.Compile) void {
self.output.addStepDependencies(&step.step);
self.props_output.addStepDependencies(&step.step);
step.root_module.addAnonymousImport("unicode_tables", .{
.root_source_file = self.output,
.root_source_file = self.props_output,
});
self.symbols_output.addStepDependencies(&step.step);
step.root_module.addAnonymousImport("symbols_tables", .{
.root_source_file = self.symbols_output,
});
}
/// Install the exe
pub fn install(self: *const UnicodeTables, b: *std.Build) void {
b.installArtifact(self.exe);
b.installArtifact(self.props_exe);
b.installArtifact(self.symbols_exe);
}