| author | |
| committer | |
| log | a34375814106dbc0e0181bca7cc4ffb1821cb51e |
| tree | d618f9b7216623a8ad9b415f29dc4c9f0d6bd155 |
| parent | f49d42729a22846ec54b6610db415ac8cdaa31db |
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.4 files changed, 5 insertions(+), 5 deletions(-)
lib/std/coff.zig+2-2| ... | @@ -276,7 +276,7 @@ pub const Coff = struct { | ... | @@ -276,7 +276,7 @@ pub const Coff = struct { |
| 276 | if (self.sections.items.len == self.coff_header.number_of_sections) | 276 | if (self.sections.items.len == self.coff_header.number_of_sections) |
| 277 | return; | 277 | return; |
| 278 | 278 | ||
| 279 | try self.sections.ensureTotalCapacity(self.coff_header.number_of_sections); | 279 | try self.sections.ensureTotalCapacityPrecise(self.coff_header.number_of_sections); |
| 280 | 280 | ||
| 281 | const in = self.in_file.reader(); | 281 | const in = self.in_file.reader(); |
| 282 | 282 | ||
| ... | @@ -297,7 +297,7 @@ pub const Coff = struct { | ... | @@ -297,7 +297,7 @@ pub const Coff = struct { |
| 297 | std.mem.set(u8, name[8..], 0); | 297 | std.mem.set(u8, name[8..], 0); |
| 298 | } | 298 | } |
| 299 | 299 | ||
| 300 | try self.sections.append(Section{ | 300 | self.sections.appendAssumeCapacity(Section{ |
| 301 | .header = SectionHeader{ | 301 | .header = SectionHeader{ |
| 302 | .name = name, | 302 | .name = name, |
| 303 | .misc = SectionHeader.Misc{ .virtual_size = try in.readIntLittle(u32) }, | 303 | .misc = SectionHeader.Misc{ .virtual_size = try in.readIntLittle(u32) }, |
src/Module.zig+1-1| ... | @@ -4146,7 +4146,7 @@ pub fn analyzeFnBody(mod: *Module, decl: *Decl, func: *Fn, arena: *Allocator) Se | ... | @@ -4146,7 +4146,7 @@ pub fn analyzeFnBody(mod: *Module, decl: *Decl, func: *Fn, arena: *Allocator) Se |
| 4146 | // for the runtime ones. | 4146 | // for the runtime ones. |
| 4147 | const fn_ty = decl.ty; | 4147 | const fn_ty = decl.ty; |
| 4148 | const runtime_params_len = @intCast(u32, fn_ty.fnParamLen()); | 4148 | const runtime_params_len = @intCast(u32, fn_ty.fnParamLen()); |
| 4149 | try inner_block.instructions.ensureTotalCapacity(gpa, runtime_params_len); | 4149 | try inner_block.instructions.ensureTotalCapacityPrecise(gpa, runtime_params_len); |
| 4150 | try sema.air_instructions.ensureUnusedCapacity(gpa, fn_info.total_params_len * 2); // * 2 for the `addType` | 4150 | try sema.air_instructions.ensureUnusedCapacity(gpa, fn_info.total_params_len * 2); // * 2 for the `addType` |
| 4151 | try sema.inst_map.ensureUnusedCapacity(gpa, fn_info.total_params_len); | 4151 | try sema.inst_map.ensureUnusedCapacity(gpa, fn_info.total_params_len); |
| 4152 | 4152 |
src/link/MachO/CodeSignature.zig+1-1| ... | @@ -102,7 +102,7 @@ pub fn calcAdhocSignature( | ... | @@ -102,7 +102,7 @@ pub fn calcAdhocSignature( |
| 102 | var buffer = try allocator.alloc(u8, page_size); | 102 | var buffer = try allocator.alloc(u8, page_size); |
| 103 | defer allocator.free(buffer); | 103 | defer allocator.free(buffer); |
| 104 | 104 | ||
| 105 | try cdir.data.ensureTotalCapacity(allocator, total_pages * hash_size + id.len + 1); | 105 | try cdir.data.ensureTotalCapacityPrecise(allocator, total_pages * hash_size + id.len + 1); |
| 106 | 106 | ||
| 107 | // 1. Save the identifier and update offsets | 107 | // 1. Save the identifier and update offsets |
| 108 | cdir.inner.identOffset = cdir.inner.length; | 108 | cdir.inner.identOffset = cdir.inner.length; |
src/link/MachO/commands.zig+1-1| ... | @@ -223,7 +223,7 @@ pub const SegmentCommand = struct { | ... | @@ -223,7 +223,7 @@ pub const SegmentCommand = struct { |
| 223 | var segment = SegmentCommand{ | 223 | var segment = SegmentCommand{ |
| 224 | .inner = inner, | 224 | .inner = inner, |
| 225 | }; | 225 | }; |
| 226 | try segment.sections.ensureTotalCapacity(alloc, inner.nsects); | 226 | try segment.sections.ensureTotalCapacityPrecise(alloc, inner.nsects); |
| 227 | 227 | ||
| 228 | var i: usize = 0; | 228 | var i: usize = 0; |
| 229 | while (i < inner.nsects) : (i += 1) { | 229 | while (i < inner.nsects) : (i += 1) { |