Carl Mäsak and mathiasbynens Build up result in array instead of strings
14b3401 Feb 12, 2018
Build up result in array instead of strings
Incrementally concatenating strings means a lot of intermediate strings get allocated only to be thrown away. The result is O(n**2) in both space and time. See this post about “Shlemiel the painter’s algorithm” for a good description about the quadratic behavior involved: https://www.joelonsoftware.com/2001/12/11/back-to-basics/

Storing each fragment in an array and joining them all together in the end at least avoids allocating ever-longer intermediate strings. I have not run any benchmarks on very long strings,
though. That might still be interesting to do.

Closes #12.
14b3401