mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-30 21:37:38 +03:00
simd: remove ziglyph fallback
This commit is contained in:
@ -15,8 +15,6 @@ namespace hn = hwy::HWY_NAMESPACE;
|
|||||||
|
|
||||||
using T = uint32_t;
|
using T = uint32_t;
|
||||||
|
|
||||||
extern "C" int8_t ghostty_ziglyph_codepoint_width(uint32_t);
|
|
||||||
|
|
||||||
// East Asian Width
|
// East Asian Width
|
||||||
HWY_ALIGN constexpr T eaw_gte[] = {
|
HWY_ALIGN constexpr T eaw_gte[] = {
|
||||||
0x3000, 0xff01, 0xffe0, 0x1100, 0x231a, 0x2329, 0x232a, 0x23e9,
|
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,
|
0xfeff, 0xfff9, 0x110bd, 0x110cd, 0x13430, 0x1bca0, 0x1d173, 0xe0001,
|
||||||
0xe0020, 0x488, 0x1abe, 0x20dd, 0x20e2, 0xa670, 0, 0,
|
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,
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
HWY_ALIGN constexpr T zero_lte[] = {
|
HWY_ALIGN constexpr T zero_lte[] = {
|
||||||
@ -82,7 +80,7 @@ HWY_ALIGN constexpr T zero_lte[] = {
|
|||||||
0xfeff, 0xfffb, 0x110bd, 0x110cd, 0x1343f, 0x1bca3, 0x1d17a, 0xe0001,
|
0xfeff, 0xfffb, 0x110bd, 0x110cd, 0x1343f, 0x1bca3, 0x1d17a, 0xe0001,
|
||||||
0xe007f, 0x489, 0x1abe, 0x20e0, 0x20e4, 0xa672, 0, 0,
|
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,
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Non-spacing marks
|
/// Non-spacing marks
|
||||||
@ -132,7 +130,7 @@ HWY_ALIGN constexpr T nsm_gte[] = {
|
|||||||
0x1e023, 0x1e026, 0x1e08f, 0x1e130, 0x1e2ae, 0x1e2ec, 0x1e4ec, 0x1e8d0,
|
0x1e023, 0x1e026, 0x1e08f, 0x1e130, 0x1e2ae, 0x1e2ec, 0x1e4ec, 0x1e8d0,
|
||||||
0x1e944, 0xe0100, 0, 0, 0, 0, 0, 0,
|
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,
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
HWY_ALIGN constexpr T nsm_lte[] = {
|
HWY_ALIGN constexpr T nsm_lte[] = {
|
||||||
@ -181,7 +179,7 @@ HWY_ALIGN constexpr T nsm_lte[] = {
|
|||||||
0x1e024, 0x1e02a, 0x1e08f, 0x1e136, 0x1e2ae, 0x1e2ef, 0x1e4ef, 0x1e8d6,
|
0x1e024, 0x1e02a, 0x1e08f, 0x1e136, 0x1e2ae, 0x1e2ef, 0x1e4ef, 0x1e8d6,
|
||||||
0x1e94a, 0xe01ef, 0, 0, 0, 0, 0, 0,
|
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,
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
// All our tables must be identically sized
|
// All our tables must be identically sized
|
||||||
@ -312,7 +310,6 @@ int8_t CodepointWidthImpl(D d, T input) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
// return ghostty_ziglyph_codepoint_width(input);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int8_t CodepointWidth(T input) {
|
int8_t CodepointWidth(T input) {
|
||||||
|
@ -22,29 +22,24 @@ test "codepointWidth basic" {
|
|||||||
// try testing.expectEqual(@as(i8, 1), @import("ziglyph").display_width.codePointWidth(0x100, .half));
|
// 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 {
|
// This is not very fast in debug modes, so its commented by default.
|
||||||
return @import("ziglyph").display_width.codePointWidth(@intCast(cp), .half);
|
// IMPORTANT: UNCOMMENT THIS WHENEVER MAKING CODEPOINTWIDTH CHANGES.
|
||||||
}
|
// test "codepointWidth matches ziglyph" {
|
||||||
|
// const testing = std.testing;
|
||||||
test "codepointWidth matches ziglyph" {
|
// const ziglyph = @import("ziglyph");
|
||||||
const testing = std.testing;
|
//
|
||||||
const ziglyph = @import("ziglyph");
|
// const min = 0xFF + 1; // start outside ascii
|
||||||
|
// for (min..std.math.maxInt(u21)) |cp| {
|
||||||
// try testing.expect(ziglyph.general_category.isNonspacingMark(0x16fe4));
|
// const simd = codepointWidth(@intCast(cp));
|
||||||
// if (true) return;
|
// const zg = ziglyph.display_width.codePointWidth(@intCast(cp), .half);
|
||||||
|
// if (simd != zg) mismatch: {
|
||||||
const min = 0xFF + 1; // start outside ascii
|
// if (cp == 0x2E3B) {
|
||||||
for (min..std.math.maxInt(u21)) |cp| {
|
// try testing.expectEqual(@as(i8, 2), simd);
|
||||||
const simd = codepointWidth(@intCast(cp));
|
// break :mismatch;
|
||||||
const zg = ziglyph.display_width.codePointWidth(@intCast(cp), .half);
|
// }
|
||||||
if (simd != zg) mismatch: {
|
//
|
||||||
if (cp == 0x2E3B) {
|
// std.log.warn("mismatch cp=U+{x} simd={} zg={}", .{ cp, simd, zg });
|
||||||
try testing.expectEqual(@as(i8, 2), simd);
|
// try testing.expect(false);
|
||||||
break :mismatch;
|
// }
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
std.log.warn("mismatch cp=U+{x} simd={} zg={}", .{ cp, simd, zg });
|
|
||||||
try testing.expect(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Reference in New Issue
Block a user