summaryrefslogtreecommitdiff
path: root/src/simd
diff options
context:
space:
mode:
authorMitchell Hashimoto <mitchell.hashimoto@gmail.com>2024-02-07 09:21:33 -0800
committerMitchell Hashimoto <mitchell.hashimoto@gmail.com>2024-02-07 09:21:33 -0800
commit46a887578ae996c9b551e8d0b4898273ac298010 (patch)
treed87dcb81487d4673b67902cd522b6df1ba26abd5 /src/simd
parent697fbe21ec2dbf55458bb9d6f178f537f3d3db44 (diff)
simd: remove ziglyph fallback
Diffstat (limited to 'src/simd')
-rw-r--r--src/simd/codepoint_width.cpp11
-rw-r--r--src/simd/codepoint_width.zig47
2 files changed, 25 insertions, 33 deletions
diff --git a/src/simd/codepoint_width.cpp b/src/simd/codepoint_width.cpp
index 22b06c3a4..5481d90c7 100644
--- a/src/simd/codepoint_width.cpp
+++ b/src/simd/codepoint_width.cpp
@@ -15,8 +15,6 @@ namespace hn = hwy::HWY_NAMESPACE;
using T = uint32_t;
-extern "C" int8_t ghostty_ziglyph_codepoint_width(uint32_t);
-
// East Asian Width
HWY_ALIGN constexpr T eaw_gte[] = {
0x3000, 0xff01, 0xffe0, 0x1100, 0x231a, 0x2329, 0x232a, 0x23e9,
@@ -74,7 +72,7 @@ HWY_ALIGN constexpr T zero_gte[] = {
0xfeff, 0xfff9, 0x110bd, 0x110cd, 0x13430, 0x1bca0, 0x1d173, 0xe0001,
0xe0020, 0x488, 0x1abe, 0x20dd, 0x20e2, 0xa670, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
};
HWY_ALIGN constexpr T zero_lte[] = {
@@ -82,7 +80,7 @@ HWY_ALIGN constexpr T zero_lte[] = {
0xfeff, 0xfffb, 0x110bd, 0x110cd, 0x1343f, 0x1bca3, 0x1d17a, 0xe0001,
0xe007f, 0x489, 0x1abe, 0x20e0, 0x20e4, 0xa672, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
};
/// Non-spacing marks
@@ -132,7 +130,7 @@ HWY_ALIGN constexpr T nsm_gte[] = {
0x1e023, 0x1e026, 0x1e08f, 0x1e130, 0x1e2ae, 0x1e2ec, 0x1e4ec, 0x1e8d0,
0x1e944, 0xe0100, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
};
HWY_ALIGN constexpr T nsm_lte[] = {
@@ -181,7 +179,7 @@ HWY_ALIGN constexpr T nsm_lte[] = {
0x1e024, 0x1e02a, 0x1e08f, 0x1e136, 0x1e2ae, 0x1e2ef, 0x1e4ef, 0x1e8d6,
0x1e94a, 0xe01ef, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
};
// All our tables must be identically sized
@@ -312,7 +310,6 @@ int8_t CodepointWidthImpl(D d, T input) {
}
return 1;
- // return ghostty_ziglyph_codepoint_width(input);
}
int8_t CodepointWidth(T input) {
diff --git a/src/simd/codepoint_width.zig b/src/simd/codepoint_width.zig
index 2be02462f..aab4bdd95 100644
--- a/src/simd/codepoint_width.zig
+++ b/src/simd/codepoint_width.zig
@@ -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);
+// }
+// }
+// }