chore: optimize batches with one item (#875)
Signed-off-by: Andres Taylor <andres@planetscale.com>
This commit is contained in:
parent
f633b8f0e3
commit
305d5b285f
1 changed files with 8 additions and 4 deletions
12
commands.go
12
commands.go
|
|
@ -20,11 +20,15 @@ func Batch(cmds ...Cmd) Cmd {
|
|||
}
|
||||
validCmds = append(validCmds, c)
|
||||
}
|
||||
if len(validCmds) == 0 {
|
||||
switch len(validCmds) {
|
||||
case 0:
|
||||
return nil
|
||||
}
|
||||
return func() Msg {
|
||||
return BatchMsg(validCmds)
|
||||
case 1:
|
||||
return validCmds[0]
|
||||
default:
|
||||
return func() Msg {
|
||||
return BatchMsg(validCmds)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue