diff options
author | 2021-06-04 02:47:07 -0700 | |
---|---|---|
committer | 2021-06-04 02:47:07 -0700 | |
commit | fa2f60cdd529c589505f2ec5fa2eb21c5abf8aaa (patch) | |
tree | fe268bc7851f7c8d8bb1c63934dcb8a7ed708a06 /src/string_mutable.zig | |
parent | 21a1134de36e25b3559fac88243d1a9e1c7ca273 (diff) | |
download | bun-fa2f60cdd529c589505f2ec5fa2eb21c5abf8aaa.tar.gz bun-fa2f60cdd529c589505f2ec5fa2eb21c5abf8aaa.tar.zst bun-fa2f60cdd529c589505f2ec5fa2eb21c5abf8aaa.zip |
fix the leaks
Former-commit-id: 58d77ab82795266ecee5f437f324db81f5706682
Diffstat (limited to 'src/string_mutable.zig')
-rw-r--r-- | src/string_mutable.zig | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/string_mutable.zig b/src/string_mutable.zig index 64ebf7601..825e5b86d 100644 --- a/src/string_mutable.zig +++ b/src/string_mutable.zig @@ -102,25 +102,31 @@ pub const MutableString = struct { } } - pub fn growBy(self: *MutableString, amount: usize) callconv(.Inline) !void { + pub inline fn growBy(self: *MutableString, amount: usize) !void { try self.list.ensureUnusedCapacity(self.allocator, amount); } - pub fn appendChar(self: *MutableString, char: u8) callconv(.Inline) !void { + pub inline fn reset( + self: *MutableString, + ) void { + self.list.shrinkRetainingCapacity(0); + } + + pub inline fn appendChar(self: *MutableString, char: u8) !void { try self.list.append(self.allocator, char); } - pub fn appendCharAssumeCapacity(self: *MutableString, char: u8) callconv(.Inline) void { + pub inline fn appendCharAssumeCapacity(self: *MutableString, char: u8) void { self.list.appendAssumeCapacity(char); } - pub fn append(self: *MutableString, char: []const u8) callconv(.Inline) !void { + pub inline fn append(self: *MutableString, char: []const u8) !void { try self.list.appendSlice(self.allocator, char); } - pub fn appendAssumeCapacity(self: *MutableString, char: []const u8) callconv(.Inline) void { + pub inline fn appendAssumeCapacity(self: *MutableString, char: []const u8) void { self.list.appendSliceAssumeCapacity( char, ); } - pub fn lenI(self: *MutableString) callconv(.Inline) i32 { + pub inline fn lenI(self: *MutableString) i32 { return @intCast(i32, self.list.items.len); } |