render: address review feedback
1. `inline` the table get. 2. Delete unused functions on the LUT table. 3. Disable the isSymbol test under valgrindpull/8528/head
parent
e024b77ad5
commit
1ef220a679
|
|
@ -83,7 +83,7 @@ pub fn Generator(
|
|||
block_len += 1;
|
||||
|
||||
// If we still have space and we're not done with codepoints,
|
||||
// we keep building up the bock. Conversely: we finalize this
|
||||
// we keep building up the block. Conversely: we finalize this
|
||||
// block if we've filled it or are out of codepoints.
|
||||
if (block_len < block_size and cp != std.math.maxInt(u21)) continue;
|
||||
if (block_len < block_size) @memset(block[block_len..block_size], 0);
|
||||
|
|
@ -136,38 +136,12 @@ pub fn Tables(comptime Elem: type) type {
|
|||
stage3: []const Elem,
|
||||
|
||||
/// Given a codepoint, returns the mapping for that codepoint.
|
||||
pub fn get(self: *const Self, cp: u21) Elem {
|
||||
pub inline fn get(self: *const Self, cp: u21) Elem {
|
||||
const high = cp >> 8;
|
||||
const low = cp & 0xFF;
|
||||
return self.stage3[self.stage2[self.stage1[high] + low]];
|
||||
}
|
||||
|
||||
pub inline fn getInline(self: *const Self, cp: u21) Elem {
|
||||
const high = cp >> 8;
|
||||
const low = cp & 0xFF;
|
||||
return self.stage3[self.stage2[self.stage1[high] + low]];
|
||||
}
|
||||
|
||||
pub fn getBool(self: *const Self, cp: u21) bool {
|
||||
assert(Elem == bool);
|
||||
assert(self.stage3.len == 2);
|
||||
assert(self.stage3[0] == false);
|
||||
assert(self.stage3[1] == true);
|
||||
const high = cp >> 8;
|
||||
const low = cp & 0xFF;
|
||||
return self.stage2[self.stage1[high] + low] != 0;
|
||||
}
|
||||
|
||||
pub inline fn getBoolInline(self: *const Self, cp: u21) bool {
|
||||
assert(Elem == bool);
|
||||
assert(self.stage3.len == 2);
|
||||
assert(self.stage3[0] == false);
|
||||
assert(self.stage3[1] == true);
|
||||
const high = cp >> 8;
|
||||
const low = cp & 0xFF;
|
||||
return self.stage2[self.stage1[high] + low] != 0;
|
||||
}
|
||||
|
||||
/// Writes the lookup table as Zig to the given writer. The
|
||||
/// written file exports three constants: stage1, stage2, and
|
||||
/// stage3. These can be used to rebuild the lookup table in Zig.
|
||||
|
|
@ -199,6 +173,7 @@ pub fn Tables(comptime Elem: type) type {
|
|||
\\};
|
||||
\\ };
|
||||
\\}
|
||||
\\
|
||||
);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -78,7 +78,9 @@ pub fn main() !void {
|
|||
|
||||
// This is not very fast in debug modes, so its commented by default.
|
||||
// IMPORTANT: UNCOMMENT THIS WHENEVER MAKING CHANGES.
|
||||
test "unicode symbols1: tables match ziglyph" {
|
||||
test "unicode symbols: tables match ziglyph" {
|
||||
if (std.valgrind.runningOnValgrind() > 0) return error.SkipZigTest;
|
||||
|
||||
const testing = std.testing;
|
||||
|
||||
for (0..std.math.maxInt(u21)) |cp| {
|
||||
|
|
|
|||
Loading…
Reference in New Issue