summaryrefslogtreecommitdiff
path: root/src/FoldData.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/FoldData.zig')
-rw-r--r--src/FoldData.zig10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/FoldData.zig b/src/FoldData.zig
index 892f78f..b7bbbd1 100644
--- a/src/FoldData.zig
+++ b/src/FoldData.zig
@@ -3,9 +3,11 @@ const builtin = @import("builtin");
3const compress = std.compress; 3const compress = std.compress;
4const mem = std.mem; 4const mem = std.mem;
5 5
6const cwcf_max = 0x1e950;
7
6allocator: mem.Allocator, 8allocator: mem.Allocator,
7cutoff: u21 = undefined, 9cutoff: u21 = undefined,
8cwcf: [0x10ffff]bool = [_]bool{false} ** 0x10ffff, 10cwcf: [cwcf_max]bool = [_]bool{false} ** cwcf_max,
9multiple_start: u21 = undefined, 11multiple_start: u21 = undefined,
10stage1: []u8 = undefined, 12stage1: []u8 = undefined,
11stage2: []u8 = undefined, 13stage2: []u8 = undefined,
@@ -54,7 +56,7 @@ pub fn deinit(self: *const Self) void {
54} 56}
55 57
56/// Returns the case fold for `cp`. 58/// Returns the case fold for `cp`.
57pub inline fn caseFold(self: Self, cp: u21, buf: []u21) []const u21 { 59pub fn caseFold(self: Self, cp: u21, buf: []u21) []const u21 {
58 if (cp >= self.cutoff) return &.{}; 60 if (cp >= self.cutoff) return &.{};
59 61
60 const stage1_val = self.stage1[cp >> 8]; 62 const stage1_val = self.stage1[cp >> 8];
@@ -80,6 +82,6 @@ pub inline fn caseFold(self: Self, cp: u21, buf: []u21) []const u21 {
80} 82}
81 83
82/// Returns true when caseFold(NFD(`cp`)) != NFD(`cp`). 84/// Returns true when caseFold(NFD(`cp`)) != NFD(`cp`).
83pub inline fn changesWhenCaseFolded(self: Self, cp: u21) bool { 85pub fn changesWhenCaseFolded(self: Self, cp: u21) bool {
84 return self.cwcf[cp]; 86 return cp < cwcf_max and self.cwcf[cp];
85} 87}