diff options
| author | 2024-02-12 19:04:50 -0400 | |
|---|---|---|
| committer | 2024-02-12 19:04:50 -0400 | |
| commit | d2a38e9c2952ec4b003a5ba58f70fc21fcf088c5 (patch) | |
| tree | 7b48d02e3505af142128c484fe76b7aee9091cf9 /src/Grapheme.zig | |
| parent | Using Trie super slow (diff) | |
| download | zg-d2a38e9c2952ec4b003a5ba58f70fc21fcf088c5.tar.gz zg-d2a38e9c2952ec4b003a5ba58f70fc21fcf088c5.tar.xz zg-d2a38e9c2952ec4b003a5ba58f70fc21fcf088c5.zip | |
Flat array
Diffstat (limited to 'src/Grapheme.zig')
| -rw-r--r-- | src/Grapheme.zig | 7 |
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 | ||
| 3 | const std = @import("std"); | 3 | const std = @import("std"); |
| 4 | const mem = std.mem; | ||
| 5 | const unicode = std.unicode; | 4 | const unicode = std.unicode; |
| 6 | 5 | ||
| 7 | const CodePoint = @import("ziglyph").CodePoint; | 6 | const CodePoint = @import("ziglyph").CodePoint; |
| 8 | const CodePointIterator = CodePoint.CodePointIterator; | 7 | const CodePointIterator = CodePoint.CodePointIterator; |
| 9 | const emoji = @import("ziglyph").emoji; | 8 | const emoji = @import("ziglyph").emoji; |
| 10 | 9 | ||
| 11 | // const gbp = @import("gbp"); | 10 | const gbp = @import("gbp"); |
| 12 | const gbp = @import("gbp.zig"); | ||
| 13 | 11 | ||
| 14 | pub const Grapheme = @This(); | 12 | pub 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 | ||