Fix cross multi command performance

In 53788ba356, I changed the cross multi
parser to issue all of the commands sequentially. This caused a
performance regression for many use cases:
https://github.com/sbt/sbt/issues/5321. This commit restores the old
behavior of `+` if the command to run has no arguments.
This commit is contained in:
Ethan Atkins 2019-12-23 14:31:15 -08:00
parent 4207362835
commit d445590d9d
1 changed files with 7 additions and 1 deletions

View File

@ -194,7 +194,13 @@ object Cross {
.sortBy(_._1)
commandsByVersion.flatMap {
case (v, commands) =>
Seq(s"$SwitchCommand $verbose $v!") ++ commands
commands match {
case Seq(c) => Seq(s"$SwitchCommand $verbose $v! $c")
case Seq() => Nil // should be unreachable
case multi if fullArgs.isEmpty =>
Seq(s"$SwitchCommand $verbose $v! all ${multi.mkString(" ")}")
case multi => Seq(s"$SwitchCommand $verbose $v!") ++ multi
}
}
}
allCommands.toList ::: CrossRestoreSessionCommand :: captureCurrentSession(state, extracted)