commit | 540bb7301a08c785a908b6b77c69f307eb85a3f5 | [log] [tgz] |
---|---|---|
author | Jonathan Amsterdam <jba@google.com> | Sat Oct 01 09:36:39 2022 -0400 |
committer | Jonathan Amsterdam <jba@google.com> | Sun Oct 02 00:36:31 2022 +0000 |
tree | 84337aa4ccd7d44cf2c99c1052041b8d3dc7abc5 | |
parent | 8f68d5e55b7f124b2c5f6deae10f9c416d2944e8 [diff] |
slog: remove some allocs from JSONHandler time.Time.MarshalJSON allocates a buffer. Inline and modify it to avoid the allocation. json.Marshal allocates for error.Error even if the Error implementation does not. Check for error first to avoid calling json.Marshal. These two changes give around a 20% speedup on the Attrs/JSON_discard benchmarks. Change-Id: I5b6aa520957c7cc7da4fc7fdb5a639d281dda5b6 Reviewed-on: https://go-review.googlesource.com/c/exp/+/436761 Run-TryBot: Jonathan Amsterdam <jba@google.com> Reviewed-by: Alan Donovan <adonovan@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
This subrepository holds experimental and deprecated (in the old
directory) packages.
The idea for this subrepository originated as the pkg/exp
directory of the main repository, but its presence there made it unavailable to users of the binary downloads of the Go installation. The subrepository has therefore been created to make it possible to go get
these packages.
Warning: Packages here are experimental and unreliable. Some may one day be promoted to the main repository or other subrepository, or they may be modified arbitrarily or even disappear altogether.
In short, code in this subrepository is not subject to the Go 1 compatibility promise. (No subrepo is, but the promise is even more likely to be violated by go.exp than the others.)
Caveat emptor.