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>
This commit is contained in:
Jarred Sumner
2023-07-21 23:27:28 -07:00
committed by GitHub
parent 1ecd9f8a18
commit 636cec03e1
8 changed files with 321 additions and 63 deletions

View File

@@ -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{},