Skip to content

Commit 275af73

Browse files
authored
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 <[email protected]>
1 parent dac3314 commit 275af73

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

gears_commands.go

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,11 @@ func (c cmdable) TFCallArgs(ctx context.Context, libName string, funcName string
110110
lf := libName + "." + funcName
111111
args := []interface{}{"TFCALL", lf, numKeys}
112112
if options != nil {
113-
if options.Keys != nil {
114-
for _, key := range options.Keys {
115-
args = append(args, key)
116-
}
113+
for _, key := range options.Keys {
114+
args = append(args, key)
117115
}
118-
if options.Arguments != nil {
119-
for _, key := range options.Arguments {
120-
args = append(args, key)
121-
}
116+
for _, key := range options.Arguments {
117+
args = append(args, key)
122118
}
123119
}
124120
cmd := NewCmd(ctx, args...)
@@ -140,15 +136,11 @@ func (c cmdable) TFCallASYNCArgs(ctx context.Context, libName string, funcName s
140136
lf := fmt.Sprintf("%s.%s", libName, funcName)
141137
args := []interface{}{"TFCALLASYNC", lf, numKeys}
142138
if options != nil {
143-
if options.Keys != nil {
144-
for _, key := range options.Keys {
145-
args = append(args, key)
146-
}
139+
for _, key := range options.Keys {
140+
args = append(args, key)
147141
}
148-
if options.Arguments != nil {
149-
for _, key := range options.Arguments {
150-
args = append(args, key)
151-
}
142+
for _, key := range options.Arguments {
143+
args = append(args, key)
152144
}
153145
}
154146
cmd := NewCmd(ctx, args...)

0 commit comments

Comments
 (0)