diff options
author | 2021-06-26 23:12:57 -0700 | |
---|---|---|
committer | 2021-06-26 23:12:57 -0700 | |
commit | b918e7e372fce947ffcfffb0e412c34bb2c6174a (patch) | |
tree | 9ed3abc513da0659c5d7ecdbb16823e0df1806c4 /src/wtf_string_mutable.zig | |
parent | b55e64ffa3617f8213485bf76b4ea0a7a0d6d3c3 (diff) | |
download | bun-b918e7e372fce947ffcfffb0e412c34bb2c6174a.tar.gz bun-b918e7e372fce947ffcfffb0e412c34bb2c6174a.tar.zst bun-b918e7e372fce947ffcfffb0e412c34bb2c6174a.zip |
wip
Former-commit-id: 506d9b81a7c9dac5dd870f6735c39df105e72fd4
Diffstat (limited to 'src/wtf_string_mutable.zig')
-rw-r--r-- | src/wtf_string_mutable.zig | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/wtf_string_mutable.zig b/src/wtf_string_mutable.zig index 2c94dae22..2d1aac522 100644 --- a/src/wtf_string_mutable.zig +++ b/src/wtf_string_mutable.zig @@ -139,7 +139,7 @@ pub const WTFStringMutable = struct { self.list.appendAssumeCapacity(char); } pub inline fn append(self: *WTFStringMutable, str: []const u8) !void { - self.growIfNeeded(str.len); + try self.growIfNeeded(str.len); var iter = strings.CodepointIterator{ .bytes = str, .i = 0 }; while (true) { @@ -148,12 +148,12 @@ pub const WTFStringMutable = struct { return; }, 0...0xFFFF => { - try self.list.append(@intCast(u16, iter.c)); + try self.list.append(self.allocator, @intCast(u16, iter.c)); }, else => { const c = iter.c - 0x10000; - try self.list.append(@intCast(u16, 0xD800 + ((c >> 10) & 0x3FF))); - try self.list.append(@intCast(u16, 0xDC00 + (c & 0x3FF))); + try self.list.append(self.allocator, @intCast(u16, 0xD800 + ((c >> 10) & 0x3FF))); + try self.list.append(self.allocator, @intCast(u16, 0xDC00 + (c & 0x3FF))); }, } } @@ -186,15 +186,15 @@ pub const WTFStringMutable = struct { return @intCast(i32, self.list.items.len); } - pub fn toOwnedSlice(self: *WTFStringMutable) string { + pub fn toOwnedSlice(self: *WTFStringMutable) []u16 { return self.list.toOwnedSlice(self.allocator); } - pub fn toOwnedSliceLeaky(self: *WTFStringMutable) string { + pub fn toOwnedSliceLeaky(self: *WTFStringMutable) []u16 { return self.list.items; } - pub fn toOwnedSliceLength(self: *WTFStringMutable, length: usize) string { + pub fn toOwnedSliceLength(self: *WTFStringMutable, length: usize) { self.list.shrinkAndFree(self.allocator, length); return self.list.toOwnedSlice(self.allocator); } |