| ... | ... | @@ -1362,11 +1362,11 @@ pub fn Aligned(comptime T: type, comptime alignment: ?mem.Alignment) type { |
| 1362 | 1362 | return self.getLast(); |
| 1363 | 1363 | } |
| 1364 | 1364 | |
| 1365 | | const init_capacity: comptime_int = @max(1, std.atomic.cache_line / @sizeOf(T)); |
| 1366 | | |
| 1367 | 1365 | /// Called when memory growth is necessary. Returns a capacity larger than |
| 1368 | 1366 | /// minimum that grows super-linearly. |
| 1369 | 1367 | pub fn growCapacity(minimum: usize) usize { |
| 1368 | if (@sizeOf(T) == 0) return math.maxInt(usize); |
| 1369 | const init_capacity: comptime_int = @max(1, std.atomic.cache_line / @sizeOf(T)); |
| 1370 | 1370 | return minimum +| (minimum / 2 + init_capacity); |
| 1371 | 1371 | } |
| 1372 | 1372 | }; |
| ... | ... | @@ -1751,6 +1751,14 @@ test "insert" { |
| 1751 | 1751 | try testing.expect(list.items[2] == 2); |
| 1752 | 1752 | try testing.expect(list.items[3] == 3); |
| 1753 | 1753 | } |
| 1754 | { |
| 1755 | var list: ArrayList(struct {}) = .empty; |
| 1756 | defer list.deinit(a); |
| 1757 | |
| 1758 | try list.insert(a, 0, .{}); |
| 1759 | try list.append(a, .{}); |
| 1760 | try testing.expect(list.items.len == 2); |
| 1761 | } |
| 1754 | 1762 | } |
| 1755 | 1763 | |
| 1756 | 1764 | test "insertSlice" { |