From 609716524169c538b7f12666c3f9bb46a0aeeb3c Mon Sep 17 00:00:00 2001 From: Jimmi Holst Christensen Date: Fri, 25 Nov 2022 20:12:25 +0100 Subject: 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. --- src/Module.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Module.zig') 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; -- cgit v1.2.3