Skip to content

Commit

Permalink
Cache more types
Browse files Browse the repository at this point in the history
  • Loading branch information
Victorious3 committed Dec 6, 2023
1 parent e2ed9d7 commit 260014a
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/compiler.pr
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ export type State = struct {
// Vector of LoopState
loops: &Vector(LoopState)
// Map of Value
ditypes: &SMap(&Value)
ditypes: &Map(&typechecking::Type, &Value)
difile: &Value
diunit: &Value
// Vector of Value
Expand Down Expand Up @@ -6430,10 +6430,7 @@ def di_type(tpe: &typechecking::Type, state: &State) -> &Value {
}

let anonymous = tpe.type_name == null
var ditpe: &Value = null
if not anonymous {
ditpe = state.ditypes.get_or_default(tpe.type_name, null)
}
var ditpe = state.ditypes.get_or_default(tpe, null)
if ditpe { return ditpe }

var name = tpe.type_name
Expand All @@ -6447,9 +6444,7 @@ def di_type(tpe: &typechecking::Type, state: &State) -> &Value {

ditpe = {} !&Value
let ditpep = push_meta(ditpe, state)
if not anonymous {
(@state).ditypes[tpe.type_name] = ditpep
}
(@state).ditypes[tpe] = ditpep

if tpe.kind == typechecking::TypeKind::BOX {
tpe = tpe.weak
Expand Down Expand Up @@ -9087,7 +9082,7 @@ export def make_state(module: &toolchain::Module) -> &State {
let state = {
module = module,
loops = vector::make(LoopState),
ditypes = map::make(type &Value),
ditypes = map::make(type &typechecking::Type, type &Value),
discope = vector::make(type &Value),
current_block = make_block(),
globals = map::make(type *),
Expand Down

0 comments on commit 260014a

Please sign in to comment.