aboutsummaryrefslogtreecommitdiff
path: root/src/Module.zig
diff options
context:
space:
mode:
authorJimmi Holst Christensen <jhc@dismail.de>2022-11-25 20:12:25 +0100
committerAndrew Kelley <andrew@ziglang.org>2022-11-27 02:10:00 -0500
commit609716524169c538b7f12666c3f9bb46a0aeeb3c (patch)
tree3c7634b5391a1bc8568b07717e988b888334f79e /src/Module.zig
parent0196010b0cdc0854286fa2442dc28b45f1278425 (diff)
downloadzig-609716524169c538b7f12666c3f9bb46a0aeeb3c.tar.gz
zig-609716524169c538b7f12666c3f9bb46a0aeeb3c.zip
Use a slice for InstMap instead of std.HashMap
The `sema.inst_map` datastructure is very often accessed. All instructions that reference the result of other instructions does a lookup into this field. Because of this, a significant amount of time, is spent in `std.HashMap.get`. This commit replaces the `HashMap` with a simpler data structure that uses the zir indexes to index into a slice for the result. See the data structure doc comment for more info.
Diffstat (limited to 'src/Module.zig')
-rw-r--r--src/Module.zig2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/Module.zig b/src/Module.zig
index bb03616dff..b7930615c8 100644
--- a/src/Module.zig
+++ b/src/Module.zig
@@ -5582,7 +5582,7 @@ pub fn analyzeFnBody(mod: *Module, func: *Fn, arena: Allocator) SemaError!Air {
const runtime_params_len = @intCast(u32, fn_ty_info.param_types.len);
try inner_block.instructions.ensureTotalCapacityPrecise(gpa, runtime_params_len);
try sema.air_instructions.ensureUnusedCapacity(gpa, fn_info.total_params_len * 2); // * 2 for the `addType`
- try sema.inst_map.ensureUnusedCapacity(gpa, fn_info.total_params_len);
+ try sema.inst_map.ensureSpaceForInstructions(gpa, fn_info.param_body);
var runtime_param_index: usize = 0;
var total_param_index: usize = 0;