From 1e85133cbf00016d69b3d43786f4cafac4a8954e Mon Sep 17 00:00:00 2001 From: guoguangwu Date: Wed, 19 Jul 2023 16:43:59 +0800 Subject: [PATCH] chore: slice append replace loop Signed-off-by: guoguangwu --- pkg/texttemplate/ast.go | 4 +--- pkg/yttlibrary/assert.go | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/pkg/texttemplate/ast.go b/pkg/texttemplate/ast.go index 9e7f32b9..99e56313 100644 --- a/pkg/texttemplate/ast.go +++ b/pkg/texttemplate/ast.go @@ -49,9 +49,7 @@ func (n *NodeRoot) AsString() string { func (n *NodeRoot) GetValues() []interface{} { var result []interface{} - for _, item := range n.Items { - result = append(result, item) - } + result = append(result, n.Items...) return result } diff --git a/pkg/yttlibrary/assert.go b/pkg/yttlibrary/assert.go index 603f7e4a..5760e9c5 100644 --- a/pkg/yttlibrary/assert.go +++ b/pkg/yttlibrary/assert.go @@ -332,9 +332,7 @@ func (m AssertModule) oneNotNullCheck(keys starlark.Sequence) core.StarlarkFunc var keysToCheck []starlark.Value if keys == nil { - for _, key := range dict.Keys() { - keysToCheck = append(keysToCheck, key) - } + keysToCheck = append(keysToCheck, dict.Keys()...) } else { var key starlark.Value keys := keys.Iterate()