PortletRequestUtil.toXML() is a heavy method, we call it to get a xml format portlet request when preparing template context.
So the problem here is we may even do not use this xml data at all, but we prepare it all the time. This is a huge waste.
This improvement makes the call to PortletRequestUtil.toXML() working in a lazy manner. So if the template processing does not need the xml data, we won't call this method.
Benchmark result(login test) shows this saves us about 10% garbage generation which gives us about 4% general performance improvement.