Skip to content

Commit 1a064b3

Browse files
committed
avoid explicit memcpy
1 parent 9410489 commit 1a064b3

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/runtime/js.zig

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,17 +1109,14 @@ pub fn Env(comptime State: type, comptime WebApis: type) type {
11091109
else => {},
11101110
},
11111111
.array => |arr| {
1112-
// Retrieve fixed-size array as slice then copy it
1112+
// Retrieve fixed-size array as slice
11131113
const slice_type = []arr.child;
11141114
const slice_value = try self.jsValueToZig(named_function, slice_type, js_value);
11151115
if (slice_value.len != arr.len) {
11161116
// Exact length match, we could allow smaller arrays, but we would not be able to communicate how many were written
11171117
return error.InvalidArgument;
11181118
}
1119-
1120-
var result: T = undefined;
1121-
@memcpy(&result, slice_value[0..arr.len]);
1122-
return result;
1119+
return @as(*T, @ptrCast(slice_value.ptr)).*;
11231120
},
11241121
.@"struct" => {
11251122
return try (self.jsValueToStruct(named_function, T, js_value)) orelse {

0 commit comments

Comments
 (0)