diff options
author | 2023-07-21 23:27:28 -0700 | |
---|---|---|
committer | 2023-07-21 23:27:28 -0700 | |
commit | 636cec03e10ab487b1df3057aaab60b4d2b02c99 (patch) | |
tree | fbf10b89dcd64270ba7fee1d78efba2b5caf2414 /src/string.zig | |
parent | 1ecd9f8a18da1af9f2090791b15a18ff3e68411d (diff) | |
download | bun-636cec03e10ab487b1df3057aaab60b4d2b02c99.tar.gz bun-636cec03e10ab487b1df3057aaab60b4d2b02c99.tar.zst bun-636cec03e10ab487b1df3057aaab60b4d2b02c99.zip |
Use WebKit's URL parser in fetch() and `bun install` (#3730)
* Use WebKit's URL parser in fetch() and `bun install`
* Allocate less memory
* Fix test
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Diffstat (limited to 'src/string.zig')
-rw-r--r-- | src/string.zig | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/string.zig b/src/string.zig index e592537c2..1e2ee752e 100644 --- a/src/string.zig +++ b/src/string.zig @@ -280,15 +280,15 @@ pub const String = extern struct { switch (this.tag) { .ZigString => return try this.value.ZigString.toOwnedSlice(allocator), .WTFStringImpl => { - var utf8_slice = this.value.WTFStringImpl.toUTF8(allocator); + var utf8_slice = this.value.WTFStringImpl.toUTF8WithoutRef(allocator); if (utf8_slice.allocator.get()) |alloc| { - if (isWTFAllocator(alloc)) { - return @constCast((try utf8_slice.clone(allocator)).slice()); + if (!isWTFAllocator(alloc)) { + return @constCast(utf8_slice.slice()); } } - return @constCast(utf8_slice.slice()); + return @constCast((try utf8_slice.clone(allocator)).slice()); }, .StaticZigString => return try this.value.StaticZigString.toOwnedSlice(allocator), .Empty => return &[_]u8{}, |