]> Cypherpunks repositories - gostls13.git/commit
debug/dwarf: optimize buf.string
authorEmmanuel T Odeke <emmanuel@orijtech.com>
Fri, 20 Sep 2019 06:35:34 +0000 (23:35 -0700)
committerEmmanuel Odeke <emm.odeke@gmail.com>
Fri, 20 Sep 2019 08:55:30 +0000 (08:55 +0000)
commit0d9981bccb0e9783b25491c9395702ca099a11e3
tree0091d7daf1f395ecd805216dabfc82c0f9c2df6d
parentbb0a8fd38f4b14f79b0da1cfe3e732f3bfb63a51
debug/dwarf: optimize buf.string

(*buf).string previously manually searched
through its underlying byte slice until we
encountered a '0'. This change instead uses
bytes.IndexByte that results in a speed up:

$ benchstat before.txt after.txt

name         old time/op    new time/op    delta
BufString-8     257ns ± 1%     174ns ± 1%  -32.37%  (p=0.000 n=9+8)

name         old speed      new speed      delta
BufString-8   495MB/s ± 1%   732MB/s ± 1%  +47.76%  (p=0.000 n=10+8)

name         old alloc/op   new alloc/op   delta
BufString-8      162B ± 0%      162B ± 0%     ~     (all equal)

name         old allocs/op  new allocs/op  delta
BufString-8      3.00 ± 0%      3.00 ± 0%     ~     (all equal)

Change-Id: I7cf241742cc091d5d30d987a168b02d83955b1cf
Reviewed-on: https://go-review.googlesource.com/c/go/+/196657
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
src/debug/dwarf/buf.go