It’s fast. Even with a boatload of iterations. Raymond’s example above simply adds a count+1 for each of the pseudo snippets above. For a reminder, please keep the snippet call in mind when viewing this explanation:
[[A? &p1=`[[B? &p1=`[[C]]` &p2=`[[D]]`]]` &p2=`[[B? &p1=`[[E]]` &p2=`[[F]]`]]`]]
So in the code demo, it evals C first, returning 1. This is because it is the first most deeply nested snippet that is truly "closed". Next D (2), then back up to the first B because it can then "close that one out" (3).
It continues to the right with A still an open snippet call. It then backs up and finds another open snippet, B. It parses out E/F (4/5), then figures out it can close out B (6). Finally, it can close out A.
Hence the 7 — simply a count of the parsing passes for the pseudo-snippets.
If you’re interested, here’s a copy of the entire code sample output:
Content Source:
[[A? &p1=`[[B? &p1=`[[C]]` &p2=`[[D]]`]]` &p2=`[[B? &p1=`[[E]]` &p2=`[[F]]`]]`]]
1) [[C]] --> output = 1
2) [[D]] --> output = 2
3) [[B? &p1=`1` &p2=`2`]] --> output = 3
4) [[E]] --> output = 4
5) [[F]] --> output = 5
6) [[B? &p1=`4` &p2=`5`]] --> output = 6
7) [[A? &p1=`3` &p2=`6`]] --> output = 7
Content for display:
7
Content for cache:
[[A? &p1=`[[B? &p1=`1` &p2=`2`]]` &p2=`[[B? &p1=`[[E]]` &p2=`5`]]`]]
Template processed within 0.0007479190826416 seconds
Very cool stuff Raymond. Now it would cache what could be cached and use that more quickly the next time through (but not in the pseudo-snippet demonstration if you were wondering)!