Skip to content

Commit 6631292

Browse files
committed
retain value, avoid str alloc
1 parent 1a064b3 commit 6631292

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/runtime/js.zig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1407,7 +1407,7 @@ pub fn Env(comptime State: type, comptime WebApis: type) type {
14071407
switch (try self.probeJsValueToZig(named_function, slice_type, js_value)) {
14081408
.value => |slice_value| {
14091409
if (slice_value.len == arr.len) {
1410-
return .{ .ok = {} };
1410+
return .{ .value = @as(*T, @ptrCast(slice_value.ptr)).* };
14111411
}
14121412
return .{ .invalid = {} };
14131413
},
@@ -1419,8 +1419,8 @@ pub fn Env(comptime State: type, comptime WebApis: type) type {
14191419
return .{ .ok = {} };
14201420
}
14211421
} else if (js_value.isString() and arr.child == u8) {
1422-
const str = try valueToString(self.call_arena, js_value, self.isolate, self.v8_context);
1423-
if (str.len == arr.len) {
1422+
const str = try js_value.toString(self.v8_context);
1423+
if (str.lenUtf8(self.isolate) == arr.len) {
14241424
return .{ .ok = {} };
14251425
}
14261426
}

0 commit comments

Comments
 (0)