Some experiments to try and improve performance, including adding a new UTF-8 benchmark for all quoters. Two big lessons:
Pre-calculating the required output buffer capacity seems to be slightly slower than letting Vec do its thing. In the end, I went with simpler-is-better and removed the pre-calculation code. If memory usage becomes a priority then it might be worth revisiting this.
Trying to outdo Vec is hard. I created a custom Chain data type to avoid reallocations – which I didn't optimise much, to be fair – but it was 2+ times slower that letting Vec follow its own reallocation strategy.
Some experiments to try and improve performance, including adding a new UTF-8 benchmark for all quoters. Two big lessons:
Vec
do its thing. In the end, I went with simpler-is-better and removed the pre-calculation code. If memory usage becomes a priority then it might be worth revisiting this.Vec
is hard. I created a customChain
data type to avoid reallocations – which I didn't optimise much, to be fair – but it was 2+ times slower that lettingVec
follow its own reallocation strategy.