| ... | ... | @@ -63,7 +63,7 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type { |
| 63 | 63 | /// Deinitialize with `deinit` or use `toOwnedSlice`. |
| 64 | 64 | pub fn initCapacity(allocator: Allocator, num: usize) Allocator.Error!Self { |
| 65 | 65 | var self = Self.init(allocator); |
| 66 | | try self.reserveTotalPrecise(num); |
| 66 | try self.reserveTotalExact(num); |
| 67 | 67 | return self; |
| 68 | 68 | } |
| 69 | 69 | |
| ... | ... | @@ -127,7 +127,7 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type { |
| 127 | 127 | /// The caller owns the returned memory. Empties this ArrayList. |
| 128 | 128 | pub fn toOwnedSliceSentinel(self: *Self, comptime sentinel: T) Allocator.Error!SentinelSlice(sentinel) { |
| 129 | 129 | // This addition can never overflow because `self.items` can never occupy the whole address space |
| 130 | | try self.reserveTotalPrecise(self.items.len + 1); |
| 130 | try self.reserveTotalExact(self.items.len + 1); |
| 131 | 131 | self.appendReserved(sentinel); |
| 132 | 132 | const result = try self.toOwnedSlice(); |
| 133 | 133 | return result[0 .. result.len - 1 :sentinel]; |
| ... | ... | @@ -473,16 +473,16 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type { |
| 473 | 473 | if (self.capacity >= new_capacity) return; |
| 474 | 474 | |
| 475 | 475 | const better_capacity = growCapacity(self.capacity, new_capacity); |
| 476 | | return self.reserveTotalPrecise(better_capacity); |
| 476 | return self.reserveTotalExact(better_capacity); |
| 477 | 477 | } |
| 478 | 478 | |
| 479 | 479 | /// Deprecated. To be removed after 0.14.0 is tagged. |
| 480 | | pub const ensureTotalCapacityPrecise = reserveTotalPrecise; |
| 480 | pub const ensureTotalCapacityPrecise = reserveTotalExact; |
| 481 | 481 | |
| 482 | 482 | /// If the current capacity is less than `new_capacity`, this function will |
| 483 | 483 | /// modify the array so that it can hold exactly `new_capacity` items. |
| 484 | 484 | /// Invalidates element pointers if additional memory is needed. |
| 485 | | pub fn reserveTotalPrecise(self: *Self, new_capacity: usize) Allocator.Error!void { |
| 485 | pub fn reserveTotalExact(self: *Self, new_capacity: usize) Allocator.Error!void { |
| 486 | 486 | if (@sizeOf(T) == 0) { |
| 487 | 487 | self.capacity = math.maxInt(usize); |
| 488 | 488 | return; |
| ... | ... | @@ -696,7 +696,7 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) typ |
| 696 | 696 | /// Deinitialize with `deinit` or use `toOwnedSlice`. |
| 697 | 697 | pub fn initCapacity(allocator: Allocator, num: usize) Allocator.Error!Self { |
| 698 | 698 | var self = Self{}; |
| 699 | | try self.reserveTotalPrecise(allocator, num); |
| 699 | try self.reserveTotalExact(allocator, num); |
| 700 | 700 | return self; |
| 701 | 701 | } |
| 702 | 702 | |
| ... | ... | @@ -763,7 +763,7 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) typ |
| 763 | 763 | /// The caller owns the returned memory. ArrayList becomes empty. |
| 764 | 764 | pub fn toOwnedSliceSentinel(self: *Self, allocator: Allocator, comptime sentinel: T) Allocator.Error!SentinelSlice(sentinel) { |
| 765 | 765 | // This addition can never overflow because `self.items` can never occupy the whole address space |
| 766 | | try self.reserveTotalPrecise(allocator, self.items.len + 1); |
| 766 | try self.reserveTotalExact(allocator, self.items.len + 1); |
| 767 | 767 | self.appendReserved(sentinel); |
| 768 | 768 | const result = try self.toOwnedSlice(allocator); |
| 769 | 769 | return result[0 .. result.len - 1 :sentinel]; |
| ... | ... | @@ -1144,16 +1144,16 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) typ |
| 1144 | 1144 | if (self.capacity >= new_capacity) return; |
| 1145 | 1145 | |
| 1146 | 1146 | const better_capacity = growCapacity(self.capacity, new_capacity); |
| 1147 | | return self.reserveTotalPrecise(allocator, better_capacity); |
| 1147 | return self.reserveTotalExact(allocator, better_capacity); |
| 1148 | 1148 | } |
| 1149 | 1149 | |
| 1150 | 1150 | /// Deprecated. To be removed after 0.14.0 is tagged. |
| 1151 | | pub const ensureTotalCapacityPrecise = reserveTotalPrecise; |
| 1151 | pub const ensureTotalCapacityPrecise = reserveTotalExact; |
| 1152 | 1152 | |
| 1153 | 1153 | /// If the current capacity is less than `new_capacity`, this function will |
| 1154 | 1154 | /// modify the array so that it can hold exactly `new_capacity` items. |
| 1155 | 1155 | /// Invalidates element pointers if additional memory is needed. |
| 1156 | | pub fn reserveTotalPrecise(self: *Self, allocator: Allocator, new_capacity: usize) Allocator.Error!void { |
| 1156 | pub fn reserveTotalExact(self: *Self, allocator: Allocator, new_capacity: usize) Allocator.Error!void { |
| 1157 | 1157 | if (@sizeOf(T) == 0) { |
| 1158 | 1158 | self.capacity = math.maxInt(usize); |
| 1159 | 1159 | return; |