Gopher Robot submitted the change![Open in Gerrit]()
Change information
Commit message:
cmd/compile: test that time.Duration.String is inlineable
This matters for encodings supporting time.Duration,
which cannot add an AppendText method due to the encoding package godoc:
Adding encoding/decoding methods to existing types may constitute
a breaking change, [...] The policy for packages maintained by
the Go project is to only allow the addition of marshaling functions
if no existing, reasonable marshaling exists.
And indeed, time.Duration does have an existing marshaling today:
as an integer, which encoding/json still uses to this day.
Thankfully, with the String method being inlineable, we can rely on
the following not allocating in the heap:
var td time.Duration = ...
b = append(b, td.String()...)
Lock this in so that we can rely on this pattern going forward.
For #77851.
Change-Id: I57ce0bc099f293b0e36aa4c74b5410f8bda347a5
Files:
- M src/cmd/compile/internal/test/inl_test.go
Change size: XS
Delta: 1 file changed, 3 insertions(+), 0 deletions(-)
Branch: refs/heads/master
Submit Requirements:
Code-Review: +2 by Keith Randall, +1 by David Chase, +1 by Keith Randall
TryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI
Open in Gerrit
Gerrit-MessageType: merged
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I57ce0bc099f293b0e36aa4c74b5410f8bda347a5
Gerrit-Change-Number: 750100
Gerrit-PatchSet: 2