From a34375814106dbc0e0181bca7cc4ffb1821cb51e Mon Sep 17 00:00:00 2001 From: Ryan Liptak Date: Mon, 1 Nov 2021 00:56:55 -0700 Subject: Update ensureTotalCapacity to ensureTotalCapacityPrecise where it makes sense These calls are all late-initialization of ArrayList's that were initialized outside the current scope. This allows us to still get the potential memory-saving benefits of the 'precision' of initCapacity. --- lib/std/coff.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/std/coff.zig') diff --git a/lib/std/coff.zig b/lib/std/coff.zig index c3823f6c53..961cd8ade6 100644 --- a/lib/std/coff.zig +++ b/lib/std/coff.zig @@ -276,7 +276,7 @@ pub const Coff = struct { if (self.sections.items.len == self.coff_header.number_of_sections) return; - try self.sections.ensureTotalCapacity(self.coff_header.number_of_sections); + try self.sections.ensureTotalCapacityPrecise(self.coff_header.number_of_sections); const in = self.in_file.reader(); @@ -297,7 +297,7 @@ pub const Coff = struct { std.mem.set(u8, name[8..], 0); } - try self.sections.append(Section{ + self.sections.appendAssumeCapacity(Section{ .header = SectionHeader{ .name = name, .misc = SectionHeader.Misc{ .virtual_size = try in.readIntLittle(u32) }, -- cgit v1.2.3