]> Cypherpunks repositories - gostls13.git/commit
strings: reduce allocation for byteReplacer
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Tue, 16 Aug 2022 03:59:05 +0000 (10:59 +0700)
committerCuong Manh Le <cuong.manhle.vn@gmail.com>
Fri, 19 Aug 2022 16:32:49 +0000 (16:32 +0000)
commit108021c195c6f43b07c437242bf39614e06b3df4
tree889f944ed8977371f8836836cfa0287db3f25b31
parentfe196a064e588d33922c1898bb3b688c5fbf3e2d
strings: reduce allocation for byteReplacer

Though it increases the execution time, the function is already quite
fast for most users, the allocation is much more important.

name                       old time/op    new time/op    delta
ByteReplacerWriteString-8    1.23µs ± 0%    2.16µs ± 1%   +75.31%  (p=0.000 n=10+10)

name                       old alloc/op   new alloc/op   delta
ByteReplacerWriteString-8    2.69kB ± 0%    0.00kB       -100.00%  (p=0.000 n=10+10)

name                       old allocs/op  new allocs/op  delta
ByteReplacerWriteString-8      1.00 ± 0%      0.00       -100.00%  (p=0.000 n=10+10)

Change-Id: I6a36df5fcb8e11ef27e6c7b252aa88e869592f3c
Reviewed-on: https://go-review.googlesource.com/c/go/+/424136
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Joedian Reid <joedian@golang.org>
src/strings/replace.go