mirror of
https://codeberg.org/kaasboteram/zig-iterating.git
synced 2025-12-15 09:43:14 +01:00
Make use of size hint in Iterator(Inner).toOwnedSlice
This commit is contained in:
parent
deb61d75ff
commit
e13cbe2d71
1 changed files with 1 additions and 1 deletions
|
|
@ -200,7 +200,7 @@ pub fn Iterator(comptime Inner: type) type {
|
|||
}
|
||||
|
||||
pub fn toOwnedSlice(self: Self, allocator: std.mem.Allocator) ![]const Item {
|
||||
var list: std.ArrayList(Item) = .empty;
|
||||
var list: std.ArrayList(Item) = if (self.sizeHint()) |num| try .initCapacity(allocator, num) else .empty;
|
||||
errdefer list.deinit(allocator);
|
||||
|
||||
try self.collectInto(&list, allocator);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue