Optimize resolving #176
Replies: 2 comments
-
Map of resolved typesIntroduce new argument that is a map (~cache) that will be updated any time we resolve some argument. That map should be expanded with both expression and it's alias (type parameter). This could help to avoid unnecessary recursive calls. v.EXPECT().
Validate(h.Inst("t1", h.Inst("int"))). // first call with t1<int>
Return(nil)
v.EXPECT().
Validate(h.Inst("int")). // first recursive call with expr's argument. after return, remember that both int and t3 (because t3 mapped onto int) are resolved
Return(nil)
v.EXPECT().
Validate(h.Inst("t2", h.Inst("t3"))). // second recursive call with expr's body.
Return(nil)
v.EXPECT().
Validate(h.Inst("t3")). // this should not happened because of map's lookup
Return(nil) ProblemsExpressions are not hashableIn theory could be solved with custom hashing (think of UPD: same strings (expression structures?) can (probably?) mean different things depending on (execution/resolving) context. That is probably a problem/ How to differ between normal types from scope and type-parametersCould be resolved with dividing cache into two separate caches. This statement should be investigated. |
Beta Was this translation helpful? Give feedback.
-
Substitution in-placeKinda did this in b7a5432 |
Beta Was this translation helpful? Give feedback.
-
Write benchmarks first
Related to #173
As we can see there's multiple
Validate
calls that could be avoided in theory. The reason of this is recursive calls. This would be even worse if those types had constraints. With bigger trees there will be many unnecessary calls.Beta Was this translation helpful? Give feedback.
All reactions