mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 07:03:29 +00:00
avoid explicit memcpy
This commit is contained in:
committed by
Muki Kiboigo
parent
a5e2e8ea15
commit
dc60fac90d
@@ -1131,17 +1131,14 @@ pub fn Env(comptime State: type, comptime WebApis: type) type {
|
||||
else => {},
|
||||
},
|
||||
.array => |arr| {
|
||||
// Retrieve fixed-size array as slice then copy it
|
||||
// Retrieve fixed-size array as slice
|
||||
const slice_type = []arr.child;
|
||||
const slice_value = try self.jsValueToZig(named_function, slice_type, js_value);
|
||||
if (slice_value.len != arr.len) {
|
||||
// Exact length match, we could allow smaller arrays, but we would not be able to communicate how many were written
|
||||
return error.InvalidArgument;
|
||||
}
|
||||
|
||||
var result: T = undefined;
|
||||
@memcpy(&result, slice_value[0..arr.len]);
|
||||
return result;
|
||||
return @as(*T, @ptrCast(slice_value.ptr)).*;
|
||||
},
|
||||
.@"struct" => {
|
||||
return try (self.jsValueToStruct(named_function, T, js_value)) orelse {
|
||||
|
||||
Reference in New Issue
Block a user