| ... | @@ -227,10 +227,11 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type { | ... | @@ -227,10 +227,11 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type { |
| 227 | /// Append the slice of items to the list, asserting the capacity is already | 227 | /// Append the slice of items to the list, asserting the capacity is already |
| 228 | /// enough to store the new items. **Does not** invalidate pointers. | 228 | /// enough to store the new items. **Does not** invalidate pointers. |
| 229 | pub fn appendSliceAssumeCapacity(self: *Self, items: []const T) void { | 229 | pub fn appendSliceAssumeCapacity(self: *Self, items: []const T) void { |
| 230 | const oldlen = self.items.len; | 230 | const old_len = self.items.len; |
| 231 | const newlen = self.items.len + items.len; | 231 | const new_len = old_len + items.len; |
| 232 | self.items.len = newlen; | 232 | assert(new_len <= self.capacity); |
| 233 | mem.copy(T, self.items[oldlen..], items); | 233 | self.items.len = new_len; |
| | 234 | mem.copy(T, self.items[old_len..], items); |
| 234 | } | 235 | } |
| 235 | | 236 | |
| 236 | pub usingnamespace if (T != u8) struct {} else struct { | 237 | pub usingnamespace if (T != u8) struct {} else struct { |
| ... | @@ -570,11 +571,11 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) typ | ... | @@ -570,11 +571,11 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) typ |
| 570 | /// Append the slice of items to the list, asserting the capacity is enough | 571 | /// Append the slice of items to the list, asserting the capacity is enough |
| 571 | /// to store the new items. | 572 | /// to store the new items. |
| 572 | pub fn appendSliceAssumeCapacity(self: *Self, items: []const T) void { | 573 | pub fn appendSliceAssumeCapacity(self: *Self, items: []const T) void { |
| 573 | const oldlen = self.items.len; | 574 | const old_len = self.items.len; |
| 574 | const newlen = self.items.len + items.len; | 575 | const new_len = old_len + items.len; |
| 575 | | 576 | assert(new_len <= self.capacity); |
| 576 | self.items.len = newlen; | 577 | self.items.len = new_len; |
| 577 | mem.copy(T, self.items[oldlen..], items); | 578 | mem.copy(T, self.items[old_len..], items); |
| 578 | } | 579 | } |
| 579 | | 580 | |
| 580 | /// Append a value to the list `n` times. | 581 | /// Append a value to the list `n` times. |