Commit ef419dd72d

Sebastian <15335529+Sobeston@users.noreply.github.com>
2020-03-30 03:57:50
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 https://github.com/ziglang/zig/issues/4847#issuecomment-605721461
1 parent 3be720a
Changed files (1)
lib
lib/std/mem.zig
@@ -341,11 +341,7 @@ pub fn zeroes(comptime T: type) T {
             }
         },
         .Array => |info| {
-            var array: T = undefined;
-            for (array) |*element| {
-                element.* = zeroes(info.child);
-            }
-            return array;
+            return [_]info.child{zeroes(info.child)} ** info.len;
         },
         .Vector,
         .ErrorUnion,