Skip to content

Commit

Permalink
refactor(gears): remove redundant nil check (#2728)
Browse files Browse the repository at this point in the history
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 <engzerjun@gmail.com>
  • Loading branch information
Juneezee authored Sep 27, 2023
1 parent dac3314 commit 275af73
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions gears_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
Expand All @@ -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...)
Expand Down

0 comments on commit 275af73

Please sign in to comment.