this repo has no description
13
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 24 lines 689 B view raw
1const std = @import("std"); 2 3const GraphemeCache = @This(); 4 5/// the underlying storage for graphemes. Right now 8kb 6buf: [1024 * 8]u8 = undefined, 7 8// the start index of the next grapheme 9idx: usize = 0, 10 11/// put a slice of bytes in the cache as a grapheme 12pub fn put(self: *GraphemeCache, bytes: []const u8) []u8 { 13 // reset the idx to 0 if we would overflow 14 if (self.idx + bytes.len > self.buf.len) self.idx = 0; 15 defer self.idx += bytes.len; 16 // copy the grapheme to our storage 17 @memcpy(self.buf[self.idx .. self.idx + bytes.len], bytes); 18 // return the slice 19 return self.buf[self.idx .. self.idx + bytes.len]; 20} 21 22test { 23 std.testing.refAllDecls(@This()); 24}