mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-28 22:53:28 +00:00
retain value, avoid str alloc
This commit is contained in:
committed by
Muki Kiboigo
parent
a7848f43cd
commit
7766892ad2
@@ -1429,7 +1429,7 @@ pub fn Env(comptime State: type, comptime WebApis: type) type {
|
||||
switch (try self.probeJsValueToZig(named_function, slice_type, js_value)) {
|
||||
.value => |slice_value| {
|
||||
if (slice_value.len == arr.len) {
|
||||
return .{ .ok = {} };
|
||||
return .{ .value = @as(*T, @ptrCast(slice_value.ptr)).* };
|
||||
}
|
||||
return .{ .invalid = {} };
|
||||
},
|
||||
@@ -1441,8 +1441,8 @@ pub fn Env(comptime State: type, comptime WebApis: type) type {
|
||||
return .{ .ok = {} };
|
||||
}
|
||||
} else if (js_value.isString() and arr.child == u8) {
|
||||
const str = try valueToString(self.call_arena, js_value, self.isolate, self.v8_context);
|
||||
if (str.len == arr.len) {
|
||||
const str = try js_value.toString(self.v8_context);
|
||||
if (str.lenUtf8(self.isolate) == arr.len) {
|
||||
return .{ .ok = {} };
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user