Commit 3ffb8fd1 authored by Sameer Ajmani's avatar Sameer Ajmani

context: fix TestAllocs to account for ints in interfaces

Recent runtime changes mean that these are stored indirectly, requiring additional allocation.

LGTM=adonovan
R=rsc, bradfitz, adonovan
CC=golang-codereviews
https://golang.org/cl/148590043
parent 91e38aee
......@@ -142,27 +142,28 @@ var Canceled = errors.New("context canceled")
// deadline passes.
var DeadlineExceeded = errors.New("context deadline exceeded")
// An emptyCtx is never canceled, has no values, and has no deadline.
// An emptyCtx is never canceled, has no values, and has no deadline. It is not
// struct{}, since vars of this type must have distinct addresses.
type emptyCtx int
func (emptyCtx) Deadline() (deadline time.Time, ok bool) {
func (*emptyCtx) Deadline() (deadline time.Time, ok bool) {
return
}
func (emptyCtx) Done() <-chan struct{} {
func (*emptyCtx) Done() <-chan struct{} {
return nil
}
func (emptyCtx) Err() error {
func (*emptyCtx) Err() error {
return nil
}
func (emptyCtx) Value(key interface{}) interface{} {
func (*emptyCtx) Value(key interface{}) interface{} {
return nil
}
func (n emptyCtx) String() string {
switch n {
func (e *emptyCtx) String() string {
switch e {
case background:
return "context.Background"
case todo:
......@@ -171,9 +172,9 @@ func (n emptyCtx) String() string {
return "unknown empty Context"
}
const (
background emptyCtx = 1
todo emptyCtx = 2
var (
background = new(emptyCtx)
todo = new(emptyCtx)
)
// Background returns a non-nil, empty Context. It is never canceled, has no
......
......@@ -365,7 +365,7 @@ func TestAllocs(t *testing.T) {
c := WithValue(bg, k1, nil)
c.Value(k1)
},
limit: 1,
limit: 3,
gccgoLimit: 3,
},
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment