diff options
| author | 2024-03-01 18:51:43 -0400 | |
|---|---|---|
| committer | 2024-03-01 18:51:43 -0400 | |
| commit | 9a0fb96c0c28540493a205b85d1b89d2c9b50f2b (patch) | |
| tree | 723760b45ef8ef604b235d10c3c60edfadd0bb70 /src/main.zig | |
| parent | Removed dupe tombstone check in Normalizer (diff) | |
| download | zg-9a0fb96c0c28540493a205b85d1b89d2c9b50f2b.tar.gz zg-9a0fb96c0c28540493a205b85d1b89d2c9b50f2b.tar.xz zg-9a0fb96c0c28540493a205b85d1b89d2c9b50f2b.zip | |
Normalizer.eqlIgnoreCase compatibility caseless matching
Diffstat (limited to 'src/main.zig')
| -rw-r--r-- | src/main.zig | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/main.zig b/src/main.zig index 59a0fbc..a5afa66 100644 --- a/src/main.zig +++ b/src/main.zig | |||
| @@ -49,21 +49,28 @@ pub fn main() !void { | |||
| 49 | var iter = std.mem.splitScalar(u8, input, '\n'); | 49 | var iter = std.mem.splitScalar(u8, input, '\n'); |
| 50 | 50 | ||
| 51 | var result: usize = 0; | 51 | var result: usize = 0; |
| 52 | var prev_line: []const u8 = ""; | ||
| 52 | // var result: isize = 0; | 53 | // var result: isize = 0; |
| 53 | var timer = try std.time.Timer.start(); | 54 | var timer = try std.time.Timer.start(); |
| 54 | 55 | ||
| 55 | // while (iter.next()) |cp| result += codePointWidth(@intCast(cp.code)); | 56 | // while (iter.next()) |cp| result += codePointWidth(@intCast(cp.code)); |
| 56 | // while (iter.next()) |_| result += 1; | 57 | // while (iter.next()) |_| result += 1; |
| 57 | // while (iter.next()) |line| result += strWidth(line, &data); | 58 | // while (iter.next()) |line| result += strWidth(line, &data); |
| 58 | while (iter.next()) |line| { | 59 | // while (iter.next()) |line| { |
| 59 | const nfc = try n.nfkc(allocator, line); | 60 | // const nfc = try n.nfkc(allocator, line); |
| 60 | result += nfc.slice.len; | 61 | // result += nfc.slice.len; |
| 61 | // nfc.deinit(); | 62 | // // nfc.deinit(); |
| 62 | } | 63 | // } |
| 63 | // while (iter.next()) |cp| { | 64 | // while (iter.next()) |cp| { |
| 64 | // if (cp.code == 'É') std.debug.print("`{u}` Gc: {s}\n", .{ cp.code, @tagName(gencat_data.gc(cp.code)) }); | 65 | // if (cp.code == 'É') std.debug.print("`{u}` Gc: {s}\n", .{ cp.code, @tagName(gencat_data.gc(cp.code)) }); |
| 65 | // result += 1; | 66 | // result += 1; |
| 66 | // } | 67 | // } |
| 68 | while (iter.next()) |line| { | ||
| 69 | if (try n.eqlIgnoreCase(allocator, prev_line, line)) { | ||
| 70 | result += line.len; | ||
| 71 | } | ||
| 72 | prev_line = line; | ||
| 73 | } | ||
| 67 | 74 | ||
| 68 | std.debug.print("result: {}, took: {}\n", .{ result, timer.lap() / std.time.ns_per_ms }); | 75 | std.debug.print("result: {}, took: {}\n", .{ result, timer.lap() / std.time.ns_per_ms }); |
| 69 | } | 76 | } |