Do you have any tutorial/guidelines how to manage ...
# compiler
h
Do you have any tutorial/guidelines how to manage the state in a transformer (IrElementTransformerVoid)? For example, I want to transform a class (add init block) for each property annotated with an annotation. In the init block I need to call a constructor of a class. When should I resolve the class? Is it okay to solve the class using
pluginContext.referenceClass
in
visitClass
each time a class visited (because it is memorized in compiler) , or should I call it once lazily and keep it in the transformer as variable? Or will be the transformer created multiple times/for each thread?
d
referenceClass
does have memorization under the hood, but you can speed it up by making your own cache, because in this way you will lookup in much smaller maps But it's worth to do it only if you are sure that it is actually a hot place which requires additional optimizations
🙏 1