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