Skip to content

Commit ef419dd

Browse files
Sobestonandrewrk
authored andcommitted
mem.zeroes .Array improvements
Before (when given an array with many elements): ``` zig\std\mem.zig:345:13: error: evaluation exceeded 1000 backwards branches for (array) |*element| { ^ ``` related to #4847 (comment)
1 parent 3be720a commit ef419dd

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

lib/std/mem.zig

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -341,11 +341,7 @@ pub fn zeroes(comptime T: type) T {
341341
}
342342
},
343343
.Array => |info| {
344-
var array: T = undefined;
345-
for (array) |*element| {
346-
element.* = zeroes(info.child);
347-
}
348-
return array;
344+
return [_]info.child{zeroes(info.child)} ** info.len;
349345
},
350346
.Vector,
351347
.ErrorUnion,

0 commit comments

Comments
 (0)