diff options
| author | Josh Bleecher Snyder <josharian@gmail.com> | 2018-04-12 12:15:58 -0700 |
|---|---|---|
| committer | Josh Bleecher Snyder <josharian@gmail.com> | 2018-04-12 22:18:18 +0000 |
| commit | 86181120bd664e195dee7f62b71771b302cc59bc (patch) | |
| tree | 1f7d36c6ff26b05efe2a3c30c43637d066cde5a1 /src/encoding | |
| parent | 3cb067d70dd3cd0e4eeb5395d9a8da8ebf199d1a (diff) | |
| download | go-86181120bd664e195dee7f62b71771b302cc59bc.tar.xz | |
os: allocate buffer lazily in Expand
As an example of why this might happen,
consider this code from cmd/internal/objfile:
// Expand literal "$GOROOT" rewritten by obj.AbsFile()
filename = filepath.Clean(os.ExpandEnv(filename))
In this case, filename might not contain "$GOROOT",
in which case we can skip the buffer entirely.
name old time/op new time/op delta
Expand/noop-8 46.7ns ± 1% 12.9ns ± 1% -72.47% (p=0.000 n=9+9)
Expand/multiple-8 139ns ± 1% 137ns ± 1% -1.36% (p=0.001 n=10+10)
The Expand/multiple improvement is probably noise.
This speeds up cmd/objdump detectably, if not much.
Using "benchcmd ObjdumpCompile go tool objdump `go tool -n compile`":
name old time/op new time/op delta
ObjdumpCompile 9.35s ± 2% 9.07s ± 3% -3.00% (p=0.000 n=18+18)
Updates #24725
Change-Id: Id31ec6a9b8dfb3c0f1db58fe1f958e11c39e656c
Reviewed-on: https://go-review.googlesource.com/106697
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/encoding')
0 files changed, 0 insertions, 0 deletions
