Skip to content

Commit f06b76a

Browse files
sjorsdonkersmookums
authored andcommitted
retain value, avoid str alloc
1 parent cb353a6 commit f06b76a

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
@@ -1429,7 +1429,7 @@ pub fn Env(comptime State: type, comptime WebApis: type) type {
14291429
switch (try self.probeJsValueToZig(named_function, slice_type, js_value)) {
14301430
.value => |slice_value| {
14311431
if (slice_value.len == arr.len) {
1432-
return .{ .ok = {} };
1432+
return .{ .value = @as(*T, @ptrCast(slice_value.ptr)).* };
14331433
}
14341434
return .{ .invalid = {} };
14351435
},
@@ -1441,8 +1441,8 @@ pub fn Env(comptime State: type, comptime WebApis: type) type {
14411441
return .{ .ok = {} };
14421442
}
14431443
} else if (js_value.isString() and arr.child == u8) {
1444-
const str = try valueToString(self.call_arena, js_value, self.isolate, self.v8_context);
1445-
if (str.len == arr.len) {
1444+
const str = try js_value.toString(self.v8_context);
1445+
if (str.lenUtf8(self.isolate) == arr.len) {
14461446
return .{ .ok = {} };
14471447
}
14481448
}

0 commit comments

Comments
 (0)