authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-06-01 03:49:35 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-06-01 03:49:35 -07:00
log427cef6d15f4eeb921555d237c8096382a098d4a
tree2b9cf44c8e228e95e7a40f637b4b17c57df36dc7
parenta61663d2e573c2295e180fa1333accbd7256acd9
signaturebadge-check Signed by SSH key SHA256:4hHJbtBRU58AYXwjL7fkz2fnQHdiye8x1QpTCQ0sHNw

move data_soa into ucd


1 files changed, 10 insertions(+), 10 deletions(-)

normalization.zig+10-10
...@@ -4,9 +4,9 @@ const std = @import("std");...@@ -4,9 +4,9 @@ const std = @import("std");
4const extras = @import("extras");4const extras = @import("extras");
5const ucd = @import("unicode-ucd");5const ucd = @import("unicode-ucd");
66
7const data = extras.StaticMultiList(ucd.unicode_data.Codepoint).initComptime(&ucd.unicode_data.data);7const ucd_data_soa = ucd.unicode_data.data_soa;
8const data_first_gap = blk: {8const data_first_gap = blk: {
9 for (data.items[0], 0..) |cp, i| {9 for (ucd_data_soa[0], 0..) |cp, i| {
10 if (cp != i) {10 if (cp != i) {
11 break :blk i;11 break :blk i;
12 }12 }
...@@ -50,16 +50,16 @@ fn Decomposition(map: *extras.ManyArrayList(u8), kind: enum { canonical, compati...@@ -50,16 +50,16 @@ fn Decomposition(map: *extras.ManyArrayList(u8), kind: enum { canonical, compati
50 while (n < map.lengths.items.len) : (n += 1) {50 while (n < map.lengths.items.len) : (n += 1) {
51 const sl = map.items(n);51 const sl = map.items(n);
52 const cp = std.unicode.utf8Decode(sl) catch unreachable;52 const cp = std.unicode.utf8Decode(sl) catch unreachable;
53 if (std.sort.binarySearch(u21, data.items[0], cp, extras.compareFnBasic(u21))) |j| {53 if (std.sort.binarySearch(u21, ucd_data_soa[0], cp, extras.compareFnBasic(u21))) |j| {
54 if (data.items[5][j] == .__none) continue;54 if (ucd_data_soa[5][j] == .__none) continue;
55 if ((data.items[5][j] == .__canonical) != (kind == .canonical)) continue;55 if ((ucd_data_soa[5][j] == .__canonical) != (kind == .canonical)) continue;
56 map.remove(n);56 map.remove(n);
57 for (data.items[6][j], 0..) |ktem, k| {57 for (ucd_data_soa[6][j], 0..) |ktem, k| {
58 var buf: [4]u8 = undefined;58 var buf: [4]u8 = undefined;
59 const l = std.unicode.utf8Encode(ktem, &buf) catch unreachable;59 const l = std.unicode.utf8Encode(ktem, &buf) catch unreachable;
60 try map.insertAt(n + k, buf[0..l]);60 try map.insertAt(n + k, buf[0..l]);
61 }61 }
62 n += data.items[6][j].len - 1;62 n += ucd_data_soa[6][j].len - 1;
63 }63 }
64 }64 }
65 // sort non-starters with respect to canonical ordering65 // sort non-starters with respect to canonical ordering
...@@ -189,10 +189,10 @@ fn CanonicalComposition(map: *extras.ManyArrayList(u8)) !void {...@@ -189,10 +189,10 @@ fn CanonicalComposition(map: *extras.ManyArrayList(u8)) !void {
189189
190pub fn cpCCC(cp: u21) u8 {190pub fn cpCCC(cp: u21) u8 {
191 if (cp < data_first_gap) {191 if (cp < data_first_gap) {
192 return data.items[3][cp];192 return ucd_data_soa[3][cp];
193 }193 }
194 if (std.sort.binarySearch(u21, data.items[0], cp, extras.compareFnBasic(u21))) |idx| {194 if (std.sort.binarySearch(u21, ucd_data_soa[0], cp, extras.compareFnBasic(u21))) |idx| {
195 return data.items[3][idx];195 return ucd_data_soa[3][idx];
196 }196 }
197 // TODO: this happens to be correct but ucd.unicode_data needs to detect the block ranges197 // TODO: this happens to be correct but ucd.unicode_data needs to detect the block ranges
198 return 0;198 return 0;