From 3c2f6d8905da2c30a0b93d0722be9c098b6d68da Mon Sep 17 00:00:00 2001 From: ferhat elmas Date: Mon, 22 Jan 2018 11:52:11 +0100 Subject: [PATCH] structs: some simplification * capacity is equal to length by default * use expand instead of for loop --- structs.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/structs.go b/structs.go index be3816a..3a87706 100644 --- a/structs.go +++ b/structs.go @@ -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)) }