The quote function was showing up in my instruments profile. The current implementation requires an allocation of a one or more strings at every step of the reduce. This version adds one character at a time and relies on the geometric growth of the string itself. I personally think it's a little clearer as well.
I considered adding reserveCapacity to the beginning, but that might be a bit of a micro-optimization.
The
quote
function was showing up in my instruments profile. The current implementation requires an allocation of a one or more strings at every step of thereduce
. This version adds one character at a time and relies on the geometric growth of the string itself. I personally think it's a little clearer as well.I considered adding
reserveCapacity
to the beginning, but that might be a bit of a micro-optimization.