diff options
author | 2023-01-28 23:23:26 -0800 | |
---|---|---|
committer | 2023-01-28 23:23:26 -0800 | |
commit | f087388ebc6314c2852d553f4f4ea3074369dfbe (patch) | |
tree | 935a0c205b3eccca29f3bcc5e3db18f7fdc4469d /src/string_immutable.zig | |
parent | 48eb0c12ab2c568d7ff706c2b0a6616d428032c8 (diff) | |
download | bun-f087388ebc6314c2852d553f4f4ea3074369dfbe.tar.gz bun-f087388ebc6314c2852d553f4f4ea3074369dfbe.tar.zst bun-f087388ebc6314c2852d553f4f4ea3074369dfbe.zip |
Support running WASI (WebAssembly) files using `bun run` (#1929)
* another micro bench
* Support running WASI
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Diffstat (limited to 'src/string_immutable.zig')
-rw-r--r-- | src/string_immutable.zig | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/string_immutable.zig b/src/string_immutable.zig index db00508e1..b02cf1249 100644 --- a/src/string_immutable.zig +++ b/src/string_immutable.zig @@ -838,6 +838,17 @@ pub inline fn append(allocator: std.mem.Allocator, self: string, other: string) return buf; } +pub inline fn append3(allocator: std.mem.Allocator, self: string, other: string, third: string) ![]u8 { + var buf = try allocator.alloc(u8, self.len + other.len + third.len); + if (self.len > 0) + @memcpy(buf.ptr, self.ptr, self.len); + if (other.len > 0) + @memcpy(buf.ptr + self.len, other.ptr, other.len); + if (third.len > 0) + @memcpy(buf.ptr + self.len + other.len, third.ptr, third.len); + return buf; +} + pub inline fn joinBuf(out: []u8, parts: anytype, comptime parts_len: usize) []u8 { var remain = out; var count: usize = 0; |