From bfb31cbc33716220b42bb398471840a4fbed0d89 Mon Sep 17 00:00:00 2001 From: Jose Colon Rodriguez Date: Mon, 12 Feb 2024 10:51:34 -0400 Subject: Using Trie super slow --- src/Grapheme.zig | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/Grapheme.zig') diff --git a/src/Grapheme.zig b/src/Grapheme.zig index a8a7638..73f6d57 100644 --- a/src/Grapheme.zig +++ b/src/Grapheme.zig @@ -1,13 +1,15 @@ //! `Grapheme` represents a Unicode grapheme cluster by its length and offset in the source bytes. const std = @import("std"); +const mem = std.mem; const unicode = std.unicode; const CodePoint = @import("ziglyph").CodePoint; const CodePointIterator = CodePoint.CodePointIterator; const emoji = @import("ziglyph").emoji; -const gbp = @import("gbp"); +// const gbp = @import("gbp"); +const gbp = @import("gbp.zig"); pub const Grapheme = @This(); @@ -32,7 +34,8 @@ pub const GraphemeIterator = struct { const Self = @This(); /// Assumes `src` is valid UTF-8. - pub fn init(str: []const u8) Self { + pub fn init(allocator: mem.Allocator, str: []const u8) !Self { + try gbp.init(allocator); var self = Self{ .cp_iter = CodePointIterator{ .bytes = str } }; self.buf[1] = self.cp_iter.next(); -- cgit v1.2.3