1
0
mirror of https://github.com/golang/go synced 2024-10-04 04:31:21 -06:00
go/src/pkg/reflect
Russ Cox 5e3224ce79 reflect: faster FieldByName, FieldByNameFunc
The old code was a depth first graph traversal that could, under the
right conditions, end up re-exploring the same subgraphs multiple
times, once for each way to arrive at that subgraph at a given depth.

The new code uses a breadth first search to make sure that it only
visits each reachable embedded struct once.

Also add fast path for the trivial case.

benchmark                old ns/op    new ns/op    delta
BenchmarkFieldByName1         1321          187  -85.84%
BenchmarkFieldByName2         6118         5186  -15.23%
BenchmarkFieldByName3      8218553        42112  -99.49%

R=gri, r
CC=golang-dev
https://golang.org/cl/6458090
2012-09-05 09:35:53 -04:00
..
all_test.go reflect: faster FieldByName, FieldByNameFunc 2012-09-05 09:35:53 -04:00
deepequal.go reflect.DeepEqual: don't panic comparing functions 2012-02-24 16:25:39 +11:00
set_test.go reflect: rename Typeof, NewValue -> TypeOf, ValueOf 2011-04-25 13:39:16 -04:00
tostring_test.go use new strconv API 2011-12-05 15:48:46 -05:00
type.go reflect: faster FieldByName, FieldByNameFunc 2012-09-05 09:35:53 -04:00
value.go reflect: reflect.Zero results are neither addressable nor settable 2012-07-03 16:06:24 -07:00