zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit b9355edfb1db042098bc232cf8e52e079f4fcf4e (tree)
parent 943dac3e8558712096d55a30897057d75444178c
Author: Andrew Kelley <andrew@ziglang.org>
Date:   Thu,  5 Dec 2024 21:32:07 -0800

std.array_list: tiny refactor for pleasure

Diffstat:
Mlib/std/array_list.zig | 6++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/lib/std/array_list.zig b/lib/std/array_list.zig @@ -267,8 +267,7 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type { /// Never invalidates element pointers. /// Asserts that the list can hold one additional item. pub fn appendAssumeCapacity(self: *Self, item: T) void { - const new_item_ptr = self.addOneAssumeCapacity(); - new_item_ptr.* = item; + self.addOneAssumeCapacity().* = item; } /// Remove the element at index `i`, shift elements after index @@ -879,8 +878,7 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) typ /// Never invalidates element pointers. /// Asserts that the list can hold one additional item. pub fn appendAssumeCapacity(self: *Self, item: T) void { - const new_item_ptr = self.addOneAssumeCapacity(); - new_item_ptr.* = item; + self.addOneAssumeCapacity().* = item; } /// Remove the element at index `i` from the list and return its value.