From: Russ Cox Date: Fri, 27 Jan 2012 21:11:17 +0000 (-0500) Subject: reflect: add comment about Type.Field allocation X-Git-Tag: weekly.2012-02-07~249 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=c4303aa59ff4c6ddb350a7d670e455426c16962b;p=gostls13.git reflect: add comment about Type.Field allocation R=golang-dev, bradfitz, r CC=golang-dev https://golang.org/cl/5586044 --- diff --git a/src/pkg/reflect/type.go b/src/pkg/reflect/type.go index 15b32efe37..0acee9e434 100644 --- a/src/pkg/reflect/type.go +++ b/src/pkg/reflect/type.go @@ -789,6 +789,14 @@ func (t *structType) Field(i int) (f StructField) { f.Tag = StructTag(*p.tag) } f.Offset = p.offset + + // NOTE(rsc): This is the only allocation in the interface + // presented by a reflect.Type. It would be nice to avoid, + // at least in the common cases, but we need to make sure + // that misbehaving clients of reflect cannot affect other + // uses of reflect. One possibility is CL 5371098, but we + // postponed that ugliness until there is a demonstrated + // need for the performance. This is issue 2320. f.Index = []int{i} return }