From b0758e99c8380acf1acff47eccfe4e9f0b6995b1 Mon Sep 17 00:00:00 2001 From: Ethan Atkins Date: Mon, 23 Dec 2019 14:31:15 -0800 Subject: [PATCH] Fix cross multi command performance In 53788ba3561a4e79bc9c36c329f43540ad48814e, 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. --- main/src/main/scala/sbt/Cross.scala | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/main/src/main/scala/sbt/Cross.scala b/main/src/main/scala/sbt/Cross.scala index ca2e8974a..2bdde84dd 100644 --- a/main/src/main/scala/sbt/Cross.scala +++ b/main/src/main/scala/sbt/Cross.scala @@ -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)