summaryrefslogtreecommitdiff
path: root/src/Grapheme.zig
diff options
context:
space:
mode:
authorGravatar Jose Colon Rodriguez2024-02-12 10:51:34 -0400
committerGravatar Jose Colon Rodriguez2024-02-12 10:51:34 -0400
commitbfb31cbc33716220b42bb398471840a4fbed0d89 (patch)
tree3f3614621f34f066bd192ce93d3f82810205e5ca /src/Grapheme.zig
parentCreated Trie (diff)
downloadzg-bfb31cbc33716220b42bb398471840a4fbed0d89.tar.gz
zg-bfb31cbc33716220b42bb398471840a4fbed0d89.tar.xz
zg-bfb31cbc33716220b42bb398471840a4fbed0d89.zip
Using Trie super slow
Diffstat (limited to 'src/Grapheme.zig')
-rw-r--r--src/Grapheme.zig7
1 files changed, 5 insertions, 2 deletions
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 @@
1//! `Grapheme` represents a Unicode grapheme cluster by its length and offset in the source bytes. 1//! `Grapheme` represents a Unicode grapheme cluster by its length and offset in the source bytes.
2 2
3const std = @import("std"); 3const std = @import("std");
4const mem = std.mem;
4const unicode = std.unicode; 5const unicode = std.unicode;
5 6
6const CodePoint = @import("ziglyph").CodePoint; 7const CodePoint = @import("ziglyph").CodePoint;
7const CodePointIterator = CodePoint.CodePointIterator; 8const CodePointIterator = CodePoint.CodePointIterator;
8const emoji = @import("ziglyph").emoji; 9const emoji = @import("ziglyph").emoji;
9 10
10const gbp = @import("gbp"); 11// const gbp = @import("gbp");
12const gbp = @import("gbp.zig");
11 13
12pub const Grapheme = @This(); 14pub const Grapheme = @This();
13 15
@@ -32,7 +34,8 @@ pub const GraphemeIterator = struct {
32 const Self = @This(); 34 const Self = @This();
33 35
34 /// Assumes `src` is valid UTF-8. 36 /// Assumes `src` is valid UTF-8.
35 pub fn init(str: []const u8) Self { 37 pub fn init(allocator: mem.Allocator, str: []const u8) !Self {
38 try gbp.init(allocator);
36 var self = Self{ .cp_iter = CodePointIterator{ .bytes = str } }; 39 var self = Self{ .cp_iter = CodePointIterator{ .bytes = str } };
37 self.buf[1] = self.cp_iter.next(); 40 self.buf[1] = self.cp_iter.next();
38 41