Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
shell: pool buffers and avoid reallocations in Quote and Join
This is a mild improvement to speed, and a substantial amortized improvement for memory usage. Pooling helps across many uses, but for Join in particular, appending to a buffer avoids the double-allocation of a slice for quoted strings followed by the string join to add the spaces. │ before.txt │ after.txt │ sec/op │ sec/op vs base Quote/Quote-10 751.6µ 737.3µ -1.89% Quote/Join-10 394.3µ 340.5µ -13.64% │ before.txt │ after.txt │ B/op │ B/op vs base Quote/Quote-10 512.0Ki 200.3Ki -60.88% Quote/Join-10 165.78Ki 56.02Ki -66.21% │ before.txt │ after.txt │ allocs/op │ allocs/op vs base Quote/Quote-10 3.000 1.000 -66.67% Quote/Join-10 1880.000 1.000 -99.95%
- Loading branch information