Skip to content

Commit bcb2d51

Browse files
diegommmantonmedv
andauthored
Improve Performance of the Type System (#824)
* export the checker and ensure no methods or fields are exported * make Checker reusable * add PatchAndCheck method to Checker, and reuse it in visitors * avoid unnecessary map and consolidate structs * make all Nature methods use pointer-receiver * added cache for type and nature information * optimize type and nature checks * more aggressively cache some partial results and add cheap checks * cache reused values * reduce copying in Nature by breaking down optional fields * enforce use of cache * improve ergonomics of FromType and NatureOf * improve struct method fetching * make cache private to Nature * first iteration improving struct reflect caching * cleaned up struct fields data * improve caching of functions data * simplify checker code * simplify and remove dead code * add checker benchmarks * address PR comments and minor improvements * rename from SetCache to Bind * make the benchmarks more fair * fix benchmark option not being applied * move Cache to be argument instead of field * merge FuncData into Optional * rename Optional to TypeData * simplify struct logic * cache builtin numeric types --------- Co-authored-by: Anton Medvedev <[email protected]>
1 parent 1c09e5e commit bcb2d51

File tree

18 files changed

+1360
-926
lines changed

18 files changed

+1360
-926
lines changed

ast/node.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func (n *base) Type() reflect.Type {
6666

6767
// SetType sets the type of the node.
6868
func (n *base) SetType(t reflect.Type) {
69-
n.nature.Type = t
69+
n.nature = nature.FromType(t)
7070
}
7171

7272
// NilNode represents nil.

0 commit comments

Comments
 (0)