Use bytes instead of strings, and slice in-place filter (see https://github.com/golang/go/wiki/SliceTricks#filter-in-place) to avoid copying strings around. In my benchmark it shows almost 2x improvement: BenchmarkString-8 1477207 10198 ns/op BenchmarkBuffer-8 1561291 7622 ns/op BenchmarkInPlace-8 2295714 5202 ns/op String is the original implementation, Buffer is an intermediary one that uses strings.Builder, and InPlace is the one from this commit. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
3.7 KiB
3.7 KiB