Would storing an intermediate template improve things?
I mean, keep a template but where the inner templates are substed,
depending on the original parameters.
Robert Rohde wrote:
A long while ago I remember looking at the parser and
realizing that
the recursive template expansion and argument handling led the parser
to run all branches of #if and #switch statements before deciding
which one to include.
In other words, given {{#if: something | statements_A | statements_B
}}, the parser was fully expanding both statements_A and statements_B
before checking #if to decide which one to keep. Obviously that is
inefficient and in the case of very complicated conditional templates
potentially very expensive.
The new preprocessor don't follow unused branches (or so were we told ;).
http://en.wikipedia.org/wiki/Template:Citation/core screams for having loops