aboutsummaryrefslogtreecommitdiff
path: root/src/string.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/string.zig')
-rw-r--r--src/string.zig8
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{},