diff options
author | 2023-05-07 23:52:05 -0700 | |
---|---|---|
committer | 2023-05-07 23:52:05 -0700 | |
commit | 56bd4100444a6f0219efc4c203aa252e1878caa6 (patch) | |
tree | 49969eec41d09a95cbd06e119e200addef6dad73 | |
parent | 35685bbc864cf8f7966fd43feedff427c2488757 (diff) | |
download | bun-56bd4100444a6f0219efc4c203aa252e1878caa6.tar.gz bun-56bd4100444a6f0219efc4c203aa252e1878caa6.tar.zst bun-56bd4100444a6f0219efc4c203aa252e1878caa6.zip |
Reduce over-allocation
-rw-r--r-- | src/bundler/bundle_v2.zig | 6 | ||||
-rw-r--r-- | src/multi_array_list.zig | 2 |
2 files changed, 4 insertions, 4 deletions
diff --git a/src/bundler/bundle_v2.zig b/src/bundler/bundle_v2.zig index 9b7aa3c57..24e6f8b3c 100644 --- a/src/bundler/bundle_v2.zig +++ b/src/bundler/bundle_v2.zig @@ -3136,7 +3136,7 @@ const LinkerGraph = struct { dynamic_import_entry_points: []const Index.Int, shadow_entry_point_range: Logger.Range, ) !void { - try this.files.ensureTotalCapacity(this.allocator, sources.len); + try this.files.setCapacity(this.allocator, sources.len); this.files.zero(); this.files_live = try BitSet.initEmpty( this.allocator, @@ -3153,7 +3153,7 @@ const LinkerGraph = struct { // Setup entry points { - try this.entry_points.ensureTotalCapacity(this.allocator, entry_points.len + use_directive_entry_points.len + dynamic_import_entry_points.len); + try this.entry_points.setCapacity(this.allocator, entry_points.len + use_directive_entry_points.len + dynamic_import_entry_points.len); this.entry_points.len = entry_points.len; var source_indices = this.entry_points.items(.source_index); @@ -3192,7 +3192,7 @@ const LinkerGraph = struct { } var import_records_list: []ImportRecord.List = this.ast.items(.import_records); - try this.meta.ensureTotalCapacity(this.allocator, import_records_list.len); + try this.meta.setCapacity(this.allocator, import_records_list.len); this.meta.len = this.ast.len; this.meta.zero(); diff --git a/src/multi_array_list.zig b/src/multi_array_list.zig index e4249ae4b..d7e3c98e6 100644 --- a/src/multi_array_list.zig +++ b/src/multi_array_list.zig @@ -393,7 +393,7 @@ pub fn MultiArrayList(comptime S: type) type { pub fn clone(self: Self, gpa: Allocator) !Self { var result = Self{}; errdefer result.deinit(gpa); - try result.ensureTotalCapacity(gpa, self.len); + try result.setCapacity(gpa, self.len); result.len = self.len; const self_slice = self.slice(); const result_slice = result.slice(); |