authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-12-03 17:09:51-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-12-03 17:09:51-08:00
log933f7baa83d3a13373ff36e5028130ce428effa8
treedf7906df0aea726d4eeabbf973afa9e2c4376058
parentb3cd5b23a228d4f2b0253d90efa9bc326338b66c

std.ArrayList: rename "precise" to "exact"

This word is shorter and has a more accurate definition.

1 files changed, 10 insertions(+), 10 deletions(-)

lib/std/array_list.zig+10-10
......@@ -63,7 +63,7 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type {
6363 /// Deinitialize with `deinit` or use `toOwnedSlice`.
6464 pub fn initCapacity(allocator: Allocator, num: usize) Allocator.Error!Self {
6565 var self = Self.init(allocator);
66 try self.reserveTotalPrecise(num);
66 try self.reserveTotalExact(num);
6767 return self;
6868 }
6969
......@@ -127,7 +127,7 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type {
127127 /// The caller owns the returned memory. Empties this ArrayList.
128128 pub fn toOwnedSliceSentinel(self: *Self, comptime sentinel: T) Allocator.Error!SentinelSlice(sentinel) {
129129 // 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);
131131 self.appendReserved(sentinel);
132132 const result = try self.toOwnedSlice();
133133 return result[0 .. result.len - 1 :sentinel];
......@@ -473,16 +473,16 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type {
473473 if (self.capacity >= new_capacity) return;
474474
475475 const better_capacity = growCapacity(self.capacity, new_capacity);
476 return self.reserveTotalPrecise(better_capacity);
476 return self.reserveTotalExact(better_capacity);
477477 }
478478
479479 /// Deprecated. To be removed after 0.14.0 is tagged.
480 pub const ensureTotalCapacityPrecise = reserveTotalPrecise;
480 pub const ensureTotalCapacityPrecise = reserveTotalExact;
481481
482482 /// If the current capacity is less than `new_capacity`, this function will
483483 /// modify the array so that it can hold exactly `new_capacity` items.
484484 /// 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 {
486486 if (@sizeOf(T) == 0) {
487487 self.capacity = math.maxInt(usize);
488488 return;
......@@ -696,7 +696,7 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) typ
696696 /// Deinitialize with `deinit` or use `toOwnedSlice`.
697697 pub fn initCapacity(allocator: Allocator, num: usize) Allocator.Error!Self {
698698 var self = Self{};
699 try self.reserveTotalPrecise(allocator, num);
699 try self.reserveTotalExact(allocator, num);
700700 return self;
701701 }
702702
......@@ -763,7 +763,7 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) typ
763763 /// The caller owns the returned memory. ArrayList becomes empty.
764764 pub fn toOwnedSliceSentinel(self: *Self, allocator: Allocator, comptime sentinel: T) Allocator.Error!SentinelSlice(sentinel) {
765765 // 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);
767767 self.appendReserved(sentinel);
768768 const result = try self.toOwnedSlice(allocator);
769769 return result[0 .. result.len - 1 :sentinel];
......@@ -1144,16 +1144,16 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) typ
11441144 if (self.capacity >= new_capacity) return;
11451145
11461146 const better_capacity = growCapacity(self.capacity, new_capacity);
1147 return self.reserveTotalPrecise(allocator, better_capacity);
1147 return self.reserveTotalExact(allocator, better_capacity);
11481148 }
11491149
11501150 /// Deprecated. To be removed after 0.14.0 is tagged.
1151 pub const ensureTotalCapacityPrecise = reserveTotalPrecise;
1151 pub const ensureTotalCapacityPrecise = reserveTotalExact;
11521152
11531153 /// If the current capacity is less than `new_capacity`, this function will
11541154 /// modify the array so that it can hold exactly `new_capacity` items.
11551155 /// 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 {
11571157 if (@sizeOf(T) == 0) {
11581158 self.capacity = math.maxInt(usize);
11591159 return;