You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Don't precompute placeholder replacements in raw HTML post-processor
Previously, the raw HTML post-processor would precompute all possible replacements for placeholders in a string, based on the HTML stash.
It would then apply a regular expression substitution using these replacements.
Finally, if the text changed, it would recurse, and do all that again.
This was inefficient because placeholders were re-computed each time it recursed, and because only a few replacements would be used anyway.
This change moves the recursion into the regular expression substitution, so that:
1. the regular expression does minimal work on the text (contrary to re-scanning text already scanned in previous frames);
2. but more importantly, replacements aren't computed ahead of time anymore (and even less *several times*), and only fetched from the HTML stash as placeholders are found in the text.
The substitution function relies on the regular expression groups ordering: we make sure to match `<p>PLACEHOLDER</p>` first, before `PLACEHOLDER`. The presence of a wrapping `p` tag indicates whether to wrap again the substitution result, or not (also depending on whether the substituted HTML is a block-level tag).
Issue-1507: #1507
0 commit comments