From 275af739718caca7af07dde35c234517d70b6b07 Mon Sep 17 00:00:00 2001 From: Eng Zer Jun Date: Wed, 27 Sep 2023 15:50:05 +0800 Subject: [PATCH] refactor(gears): remove redundant nil check (#2728) From the Go specification: "1. For a nil slice, the number of iterations is 0." [1] Therefore, an additional nil check for before the loop is unnecessary. [1]: https://go.dev/ref/spec#For_range Signed-off-by: Eng Zer Jun --- gears_commands.go | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/gears_commands.go b/gears_commands.go index 0c67cdf2..e0d49a6b 100644 --- a/gears_commands.go +++ b/gears_commands.go @@ -110,15 +110,11 @@ func (c cmdable) TFCallArgs(ctx context.Context, libName string, funcName string lf := libName + "." + funcName args := []interface{}{"TFCALL", lf, numKeys} if options != nil { - if options.Keys != nil { - for _, key := range options.Keys { - args = append(args, key) - } + for _, key := range options.Keys { + args = append(args, key) } - if options.Arguments != nil { - for _, key := range options.Arguments { - args = append(args, key) - } + for _, key := range options.Arguments { + args = append(args, key) } } cmd := NewCmd(ctx, args...) @@ -140,15 +136,11 @@ func (c cmdable) TFCallASYNCArgs(ctx context.Context, libName string, funcName s lf := fmt.Sprintf("%s.%s", libName, funcName) args := []interface{}{"TFCALLASYNC", lf, numKeys} if options != nil { - if options.Keys != nil { - for _, key := range options.Keys { - args = append(args, key) - } + for _, key := range options.Keys { + args = append(args, key) } - if options.Arguments != nil { - for _, key := range options.Arguments { - args = append(args, key) - } + for _, key := range options.Arguments { + args = append(args, key) } } cmd := NewCmd(ctx, args...)