Phpdocx has to go through all the xml to find variables and replace them.
One of my hundreds of variables in a page is called $c12lvl1$.
But in the docx it is stored as follows:
HTML Code:
<w:r>
<w:t>$c12</w:t>
</w:r>
<w:r w:rsidR="00323925">
<w:t>lv1$</w:t>
</w:r>
So a quick search for $c12lvl1$ will not result in anything. Therefore, phpdocx will have to go through the xml and remove all those unneeded tags like the rsidR tag above.
That takes 3-4 seconds per page which makes processing time way too long for a 10-page document.
If I can do that cleanup before saving my docx template I would save 3 seconds per page every time it's generated.