Improve performance when repeating a string many times

Thanks to @dtao for the suggestion!

Closes #4.