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.
This commit is contained in:
committed by
Andrew Kelley
parent
0196010b0c
commit
6097165241
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user