authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-12-05 21:32:07-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-01-15 15:11:35-08:00
logb9355edfb1db042098bc232cf8e52e079f4fcf4e
treedd82909008b8c755d8ce99f1d2a5fa5e6d679f34
parent943dac3e8558712096d55a30897057d75444178c

std.array_list: tiny refactor for pleasure


1 files changed, 2 insertions(+), 4 deletions(-)

lib/std/array_list.zig+2-4
...@@ -267,8 +267,7 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type {...@@ -267,8 +267,7 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type {
267 /// Never invalidates element pointers.267 /// Never invalidates element pointers.
268 /// Asserts that the list can hold one additional item.268 /// Asserts that the list can hold one additional item.
269 pub fn appendAssumeCapacity(self: *Self, item: T) void {269 pub fn appendAssumeCapacity(self: *Self, item: T) void {
270 const new_item_ptr = self.addOneAssumeCapacity();270 self.addOneAssumeCapacity().* = item;
271 new_item_ptr.* = item;
272 }271 }
273272
274 /// Remove the element at index `i`, shift elements after index273 /// Remove the element at index `i`, shift elements after index
...@@ -879,8 +878,7 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) typ...@@ -879,8 +878,7 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) typ
879 /// Never invalidates element pointers.878 /// Never invalidates element pointers.
880 /// Asserts that the list can hold one additional item.879 /// Asserts that the list can hold one additional item.
881 pub fn appendAssumeCapacity(self: *Self, item: T) void {880 pub fn appendAssumeCapacity(self: *Self, item: T) void {
882 const new_item_ptr = self.addOneAssumeCapacity();881 self.addOneAssumeCapacity().* = item;
883 new_item_ptr.* = item;
884 }882 }
885883
886 /// Remove the element at index `i` from the list and return its value.884 /// Remove the element at index `i` from the list and return its value.