Add VariableOptimizerNodeVisitor
This is the simplest useful node visitor that use the new types information to optimize the compiled code.
I think that this node visitor must also enforce the availability of the variable at runtime to make this works correctly.
Like converting the types tag to checks that would throw exceptions based on the existence of the variables and maybe checking the types as well. The more I think about it, the more I think that this would be like a "strict" mode that would enable these performance optimizations.
WDYT /cc @jdreesen @ruudk?
Did you mean @drjayvee instead?
Did you mean @drjayvee instead?
Oops, sorry for the wrong ping.
This is the simplest useful node visitor that use the new types information to optimize the compiled code.
Sure, but it does add an exception for strict_variables, namely that typed variables never default to null even if strict_variables is disabled.
I think that this node visitor must also enforce the availability of the variable at runtime to make this works correctly Like converting the types tag to checks that would throw exceptions based on the existence of the variables and maybe checking the types as well. The more I think about it, the more I think that this would be like a "strict" mode that would enable these performance optimizations.
~~When you say "checking the types", I'm assuming you mean a run-time check? The other meaning is compile-time validation of the type to see whether it is valid, and whether a class (or interface, trait) exists.~~
Sorry, I didn't read your comment properly.
Aside from the run-time checks, there's also the (possible) compile-time validation of the type to check whether it is valid, and whether a given class (or interface, trait) exists.
TwigQI does all of those already. I wouldn't mind bringing some of its functionality into Twig core.
However, all of these require that we first standardize the typing system and syntax. That discussion in #4532 proved to be controversial. I wouldn't mind having another go at it, however.