From 6c7da0b526959840240177c0defb680e76fecad6 Mon Sep 17 00:00:00 2001 From: Jose Colon Rodriguez Date: Sun, 18 Feb 2024 11:14:43 -0400 Subject: Testing Ghostty's Utf8Decoder. A bit slower --- src/Grapheme.zig | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) (limited to 'src/Grapheme.zig') diff --git a/src/Grapheme.zig b/src/Grapheme.zig index 6981753..f013aba 100644 --- a/src/Grapheme.zig +++ b/src/Grapheme.zig @@ -1,6 +1,7 @@ const std = @import("std"); const unicode = std.unicode; +const CodePoint = @import("code_point").CodePoint; const CodePointIterator = @import("code_point").Iterator; const gbp = @import("gbp"); @@ -16,13 +17,6 @@ pub const Grapheme = struct { } }; -// We need the code as a u21. -const CodePoint = struct { - code: u21, - len: u3, - offset: u32, -}; - /// `Iterator` iterates a sting of UTF-8 encoded bytes one grapheme cluster at-a-time. pub const Iterator = struct { buf: [2]?CodePoint = .{ null, null }, @@ -39,13 +33,7 @@ pub const Iterator = struct { fn advance(self: *Self) void { self.buf[0] = self.buf[1]; - - const maybe_cp = self.cp_iter.next(); - self.buf[1] = if (maybe_cp) |cp| .{ - .code = cp.code(self.cp_iter.bytes), - .len = cp.len, - .offset = cp.offset, - } else null; + self.buf[1] = self.cp_iter.next(); } pub fn next(self: *Self) ?Grapheme { -- cgit v1.2.3