It the JUG 2017 conference one of the slides I presented was showing how I significantly improved the building of a large resultant string, reducing the time to build the string from 30s to under 100ms, on average.
Attached is a sample schema that shows the timing difference for building the same string using standard string concatenation and then using the more optimised version. For 100,000 executions, the default, it takes between 7s and 8s using standard concatenation and < 100ms using the optimised version. Your mileage from this may be vary, particularly if the way you obtain a given string requires accessing multiple objects, but I thought it was still worthwhile sharing the sample code for the benefit of those who were unable to attend the JUG 2017 conference or those who weren't able to copy down the sample code quickly enough while I had it on-screen.
Disclaimer: I believe that this sample code is accurate and reliable and has been prepared with care but I give no guarantee that the sample code will be free of defects or errors. No responsibility or liability, financial or otherwise, is accepted for any consequences arising out of the use of this sample code including loss of profits, indirect, special or consequential losses or damages.
Cheers,
BeeJay.