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") {
|
||||
// look out for embedded structs, and convert them to a
|
||||
// []interface{} to be added to the final values slice
|
||||
for _, embeddedVal := range Values(val.Interface()) {
|
||||
t = append(t, embeddedVal)
|
||||
}
|
||||
t = append(t, Values(val.Interface())...)
|
||||
} else {
|
||||
t = append(t, val.Interface())
|
||||
}
|
||||
@ -573,7 +571,7 @@ func (s *Struct) nested(val reflect.Value) interface{} {
|
||||
break
|
||||
}
|
||||
|
||||
slices := make([]interface{}, val.Len(), val.Len())
|
||||
slices := make([]interface{}, val.Len())
|
||||
for x := 0; x < val.Len(); x++ {
|
||||
slices[x] = s.nested(val.Index(x))
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user