summaryrefslogtreecommitdiff
path: root/src/Grapheme.zig
diff options
context:
space:
mode:
authorGravatar Jose Colon Rodriguez2024-02-12 19:04:50 -0400
committerGravatar Jose Colon Rodriguez2024-02-12 19:04:50 -0400
commitd2a38e9c2952ec4b003a5ba58f70fc21fcf088c5 (patch)
tree7b48d02e3505af142128c484fe76b7aee9091cf9 /src/Grapheme.zig
parentUsing Trie super slow (diff)
downloadzg-d2a38e9c2952ec4b003a5ba58f70fc21fcf088c5.tar.gz
zg-d2a38e9c2952ec4b003a5ba58f70fc21fcf088c5.tar.xz
zg-d2a38e9c2952ec4b003a5ba58f70fc21fcf088c5.zip
Flat array
Diffstat (limited to 'src/Grapheme.zig')
-rw-r--r--src/Grapheme.zig7
1 files changed, 2 insertions, 5 deletions
diff --git a/src/Grapheme.zig b/src/Grapheme.zig
index 73f6d57..a8a7638 100644
--- a/src/Grapheme.zig
+++ b/src/Grapheme.zig
@@ -1,15 +1,13 @@
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;
5const unicode = std.unicode; 4const unicode = std.unicode;
6 5
7const CodePoint = @import("ziglyph").CodePoint; 6const CodePoint = @import("ziglyph").CodePoint;
8const CodePointIterator = CodePoint.CodePointIterator; 7const CodePointIterator = CodePoint.CodePointIterator;
9const emoji = @import("ziglyph").emoji; 8const emoji = @import("ziglyph").emoji;
10 9
11// const gbp = @import("gbp"); 10const gbp = @import("gbp");
12const gbp = @import("gbp.zig");
13 11
14pub const Grapheme = @This(); 12pub const Grapheme = @This();
15 13
@@ -34,8 +32,7 @@ pub const GraphemeIterator = struct {
34 const Self = @This(); 32 const Self = @This();
35 33
36 /// Assumes `src` is valid UTF-8. 34 /// Assumes `src` is valid UTF-8.
37 pub fn init(allocator: mem.Allocator, str: []const u8) !Self { 35 pub fn init(str: []const u8) Self {
38 try gbp.init(allocator);
39 var self = Self{ .cp_iter = CodePointIterator{ .bytes = str } }; 36 var self = Self{ .cp_iter = CodePointIterator{ .bytes = str } };
40 self.buf[1] = self.cp_iter.next(); 37 self.buf[1] = self.cp_iter.next();
41 38