structs: some simplification
* capacity is equal to length by default * use expand instead of for loop
This commit is contained in:
parent
81b59bf1b3
commit
3c2f6d8905
@ -203,9 +203,7 @@ func (s *Struct) Values() []interface{} {
|
|||||||
if IsStruct(val.Interface()) && !tagOpts.Has("omitnested") {
|
if IsStruct(val.Interface()) && !tagOpts.Has("omitnested") {
|
||||||
// look out for embedded structs, and convert them to a
|
// look out for embedded structs, and convert them to a
|
||||||
// []interface{} to be added to the final values slice
|
// []interface{} to be added to the final values slice
|
||||||
for _, embeddedVal := range Values(val.Interface()) {
|
t = append(t, Values(val.Interface())...)
|
||||||
t = append(t, embeddedVal)
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
t = append(t, val.Interface())
|
t = append(t, val.Interface())
|
||||||
}
|
}
|
||||||
@ -573,7 +571,7 @@ func (s *Struct) nested(val reflect.Value) interface{} {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
slices := make([]interface{}, val.Len(), val.Len())
|
slices := make([]interface{}, val.Len())
|
||||||
for x := 0; x < val.Len(); x++ {
|
for x := 0; x < val.Len(); x++ {
|
||||||
slices[x] = s.nested(val.Index(x))
|
slices[x] = s.nested(val.Index(x))
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user