mirror of https://github.com/golang/go.git
reflect: add fast path for FieldByIndex with len(index) = 1
LGTM=r R=r CC=golang-codereviews https://golang.org/cl/152640043
This commit is contained in:
parent
cb6f5ac0b0
commit
94950afdf8
|
|
@ -857,6 +857,9 @@ func (v Value) Field(i int) Value {
|
|||
// FieldByIndex returns the nested field corresponding to index.
|
||||
// It panics if v's Kind is not struct.
|
||||
func (v Value) FieldByIndex(index []int) Value {
|
||||
if len(index) == 1 {
|
||||
return v.Field(index[0])
|
||||
}
|
||||
v.mustBe(Struct)
|
||||
for i, x := range index {
|
||||
if i > 0 {
|
||||
|
|
|
|||
Loading…
Reference in New Issue