| ... | ... | @@ -196,13 +196,8 @@ test "Allocator.resize" { |
| 196 | 196 | /// dest.len must be >= source.len. |
| 197 | 197 | /// If the slices overlap, dest.ptr must be <= src.ptr. |
| 198 | 198 | pub fn copy(comptime T: type, dest: []T, source: []const T) void { |
| 199 | | // TODO instead of manually doing this check for the whole array |
| 200 | | // and turning off runtime safety, the compiler should detect loops like |
| 201 | | // this and automatically omit safety checks for loops |
| 202 | | @setRuntimeSafety(false); |
| 203 | | assert(dest.len >= source.len); |
| 204 | | for (source, 0..) |s, i| |
| 205 | | dest[i] = s; |
| 199 | for (dest[0..source.len], source) |*d, s| |
| 200 | d.* = s; |
| 206 | 201 | } |
| 207 | 202 | |
| 208 | 203 | /// Copy all of source into dest at position 0. |
| ... | ... | @@ -611,8 +606,8 @@ test "lessThan" { |
| 611 | 606 | pub fn eql(comptime T: type, a: []const T, b: []const T) bool { |
| 612 | 607 | if (a.len != b.len) return false; |
| 613 | 608 | if (a.ptr == b.ptr) return true; |
| 614 | | for (a, 0..) |item, index| { |
| 615 | | if (b[index] != item) return false; |
| 609 | for (a, b) |a_elem, b_elem| { |
| 610 | if (a_elem != b_elem) return false; |
| 616 | 611 | } |
| 617 | 612 | return true; |
| 618 | 613 | } |