| author | |
| committer | |
| log | 70ef9bc75c42ec00e9d4231a2e1f1dca84144748 |
| tree | e172783da32798ca11c3b28c43cbcffb05fbf9d5 |
| parent | 77eefebe65fc2baed08755bceb8e4df77fe8103c |
If these functions are called more than once, then the array list would no longer be guaranteed to have enough capacity during the appendAssumeCapacity calls. With ensureUnusedCapacity, they will always be guaranteed to have enough capacity regardless of how many times the function is called.3 files changed, 3 insertions(+), 3 deletions(-)
src/codegen/spirv.zig+1-1| ... | @@ -629,7 +629,7 @@ pub const DeclGen = struct { | ... | @@ -629,7 +629,7 @@ pub const DeclGen = struct { |
| 629 | const params = decl.ty.fnParamLen(); | 629 | const params = decl.ty.fnParamLen(); |
| 630 | var i: usize = 0; | 630 | var i: usize = 0; |
| 631 | 631 | ||
| 632 | try self.args.ensureTotalCapacity(params); | 632 | try self.args.ensureUnusedCapacity(params); |
| 633 | while (i < params) : (i += 1) { | 633 | while (i < params) : (i += 1) { |
| 634 | const param_type_id = self.spv.types.get(decl.ty.fnParamType(i)).?; | 634 | const param_type_id = self.spv.types.get(decl.ty.fnParamType(i)).?; |
| 635 | const arg_result_id = self.spv.allocResultId(); | 635 | const arg_result_id = self.spv.allocResultId(); |
src/link/MachO/Dylib.zig+1-1| ... | @@ -180,7 +180,7 @@ pub fn parse(self: *Dylib, allocator: *Allocator, target: std.Target) !void { | ... | @@ -180,7 +180,7 @@ pub fn parse(self: *Dylib, allocator: *Allocator, target: std.Target) !void { |
| 180 | fn readLoadCommands(self: *Dylib, allocator: *Allocator, reader: anytype) !void { | 180 | fn readLoadCommands(self: *Dylib, allocator: *Allocator, reader: anytype) !void { |
| 181 | const should_lookup_reexports = self.header.?.flags & macho.MH_NO_REEXPORTED_DYLIBS == 0; | 181 | const should_lookup_reexports = self.header.?.flags & macho.MH_NO_REEXPORTED_DYLIBS == 0; |
| 182 | 182 | ||
| 183 | try self.load_commands.ensureTotalCapacity(allocator, self.header.?.ncmds); | 183 | try self.load_commands.ensureUnusedCapacity(allocator, self.header.?.ncmds); |
| 184 | 184 | ||
| 185 | var i: u16 = 0; | 185 | var i: u16 = 0; |
| 186 | while (i < self.header.?.ncmds) : (i += 1) { | 186 | while (i < self.header.?.ncmds) : (i += 1) { |
src/link/MachO/Object.zig+1-1| ... | @@ -267,7 +267,7 @@ pub fn readLoadCommands(self: *Object, allocator: *Allocator, reader: anytype) ! | ... | @@ -267,7 +267,7 @@ pub fn readLoadCommands(self: *Object, allocator: *Allocator, reader: anytype) ! |
| 267 | const header = self.header orelse unreachable; // Unreachable here signifies a fatal unexplored condition. | 267 | const header = self.header orelse unreachable; // Unreachable here signifies a fatal unexplored condition. |
| 268 | const offset = self.file_offset orelse 0; | 268 | const offset = self.file_offset orelse 0; |
| 269 | 269 | ||
| 270 | try self.load_commands.ensureTotalCapacity(allocator, header.ncmds); | 270 | try self.load_commands.ensureUnusedCapacity(allocator, header.ncmds); |
| 271 | 271 | ||
| 272 | var i: u16 = 0; | 272 | var i: u16 = 0; |
| 273 | while (i < header.ncmds) : (i += 1) { | 273 | while (i < header.ncmds) : (i += 1) { |