diff options
| author | 2025-04-30 11:58:19 -0400 | |
|---|---|---|
| committer | 2025-04-30 11:58:19 -0400 | |
| commit | 1be5e46490e061761b4b97dff5c6acb2181d6fe9 (patch) | |
| tree | 77a1edcdedd7afae7428e92feba37d2bb1035b22 /src/GraphemeData.zig | |
| parent | Add general tests step (diff) | |
| download | zg-1be5e46490e061761b4b97dff5c6acb2181d6fe9.tar.gz zg-1be5e46490e061761b4b97dff5c6acb2181d6fe9.tar.xz zg-1be5e46490e061761b4b97dff5c6acb2181d6fe9.zip | |
Factor out 'Data' for grapheme and DisplayWidth
In the process of refactoring the whole library, so that it doesn't
expose anything called "Data" separately from user functionality.
Diffstat (limited to 'src/GraphemeData.zig')
| -rw-r--r-- | src/GraphemeData.zig | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/GraphemeData.zig b/src/GraphemeData.zig index 6d3174d..df025cb 100644 --- a/src/GraphemeData.zig +++ b/src/GraphemeData.zig | |||
| @@ -36,7 +36,7 @@ s3: []u8 = undefined, | |||
| 36 | 36 | ||
| 37 | const Self = @This(); | 37 | const Self = @This(); |
| 38 | 38 | ||
| 39 | pub fn init(allocator: mem.Allocator) mem.Allocator.Error!Self { | 39 | pub inline fn init(allocator: mem.Allocator) mem.Allocator.Error!Self { |
| 40 | const decompressor = compress.flate.inflate.decompressor; | 40 | const decompressor = compress.flate.inflate.decompressor; |
| 41 | const in_bytes = @embedFile("gbp"); | 41 | const in_bytes = @embedFile("gbp"); |
| 42 | var in_fbs = std.io.fixedBufferStream(in_bytes); | 42 | var in_fbs = std.io.fixedBufferStream(in_bytes); |
| @@ -65,23 +65,23 @@ pub fn init(allocator: mem.Allocator) mem.Allocator.Error!Self { | |||
| 65 | return self; | 65 | return self; |
| 66 | } | 66 | } |
| 67 | 67 | ||
| 68 | pub fn deinit(self: *const Self, allocator: mem.Allocator) void { | 68 | pub inline fn deinit(self: *const Self, allocator: mem.Allocator) void { |
| 69 | allocator.free(self.s1); | 69 | allocator.free(self.s1); |
| 70 | allocator.free(self.s2); | 70 | allocator.free(self.s2); |
| 71 | allocator.free(self.s3); | 71 | allocator.free(self.s3); |
| 72 | } | 72 | } |
| 73 | 73 | ||
| 74 | /// Lookup the grapheme break property for a code point. | 74 | /// Lookup the grapheme break property for a code point. |
| 75 | pub fn gbp(self: Self, cp: u21) Gbp { | 75 | pub inline fn gbp(self: Self, cp: u21) Gbp { |
| 76 | return @enumFromInt(self.s3[self.s2[self.s1[cp >> 8] + (cp & 0xff)]] >> 4); | 76 | return @enumFromInt(self.s3[self.s2[self.s1[cp >> 8] + (cp & 0xff)]] >> 4); |
| 77 | } | 77 | } |
| 78 | 78 | ||
| 79 | /// Lookup the indic syllable type for a code point. | 79 | /// Lookup the indic syllable type for a code point. |
| 80 | pub fn indic(self: Self, cp: u21) Indic { | 80 | pub inline fn indic(self: Self, cp: u21) Indic { |
| 81 | return @enumFromInt((self.s3[self.s2[self.s1[cp >> 8] + (cp & 0xff)]] >> 1) & 0x7); | 81 | return @enumFromInt((self.s3[self.s2[self.s1[cp >> 8] + (cp & 0xff)]] >> 1) & 0x7); |
| 82 | } | 82 | } |
| 83 | 83 | ||
| 84 | /// Lookup the indic syllable type for a code point. | 84 | /// Lookup the emoji property for a code point. |
| 85 | pub fn isEmoji(self: Self, cp: u21) bool { | 85 | pub inline fn isEmoji(self: Self, cp: u21) bool { |
| 86 | return self.s3[self.s2[self.s1[cp >> 8] + (cp & 0xff)]] & 1 == 1; | 86 | return self.s3[self.s2[self.s1[cp >> 8] + (cp & 0xff)]] & 1 == 1; |
| 87 | } | 87 | } |