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