simd: remove ziglyph fallback

This commit is contained in:
Mitchell Hashimoto
2024-02-07 09:21:33 -08:00
parent 697fbe21ec
commit 46a887578a
2 changed files with 25 additions and 33 deletions

View File

@@ -22,29 +22,24 @@ test "codepointWidth basic" {
// try testing.expectEqual(@as(i8, 1), @import("ziglyph").display_width.codePointWidth(0x100, .half));
}
pub export fn ghostty_ziglyph_codepoint_width(cp: u32) callconv(.C) i8 {
return @import("ziglyph").display_width.codePointWidth(@intCast(cp), .half);
}
test "codepointWidth matches ziglyph" {
const testing = std.testing;
const ziglyph = @import("ziglyph");
// try testing.expect(ziglyph.general_category.isNonspacingMark(0x16fe4));
// if (true) return;
const min = 0xFF + 1; // start outside ascii
for (min..std.math.maxInt(u21)) |cp| {
const simd = codepointWidth(@intCast(cp));
const zg = ziglyph.display_width.codePointWidth(@intCast(cp), .half);
if (simd != zg) mismatch: {
if (cp == 0x2E3B) {
try testing.expectEqual(@as(i8, 2), simd);
break :mismatch;
}
std.log.warn("mismatch cp=U+{x} simd={} zg={}", .{ cp, simd, zg });
try testing.expect(false);
}
}
}
// This is not very fast in debug modes, so its commented by default.
// IMPORTANT: UNCOMMENT THIS WHENEVER MAKING CODEPOINTWIDTH CHANGES.
// test "codepointWidth matches ziglyph" {
// const testing = std.testing;
// const ziglyph = @import("ziglyph");
//
// const min = 0xFF + 1; // start outside ascii
// for (min..std.math.maxInt(u21)) |cp| {
// const simd = codepointWidth(@intCast(cp));
// const zg = ziglyph.display_width.codePointWidth(@intCast(cp), .half);
// if (simd != zg) mismatch: {
// if (cp == 0x2E3B) {
// try testing.expectEqual(@as(i8, 2), simd);
// break :mismatch;
// }
//
// std.log.warn("mismatch cp=U+{x} simd={} zg={}", .{ cp, simd, zg });
// try testing.expect(false);
// }
// }
// }