From a7848f43cd488a82f4c72b4677a6047dc900c790 Mon Sep 17 00:00:00 2001 From: sjorsdonkers <72333389+sjorsdonkers@users.noreply.github.com> Date: Fri, 5 Sep 2025 16:50:04 +0200 Subject: [PATCH] avoid explicit memcpy --- src/runtime/js.zig | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/runtime/js.zig b/src/runtime/js.zig index 996a9ebd..d5042968 100644 --- a/src/runtime/js.zig +++ b/src/runtime/js.zig @@ -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 {