Skip to content

Commit

Permalink
chore: optimize batches with one item (#875)
Browse files Browse the repository at this point in the history
Signed-off-by: Andres Taylor <andres@planetscale.com>
  • Loading branch information
systay authored Mar 1, 2024
1 parent f633b8f commit 305d5b2
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}

Expand Down

0 comments on commit 305d5b2

Please sign in to comment.