Skip to content

Commit 6631196

Browse files
committed
Avoid eager patch history lookup
1 parent 52b83cc commit 6631196

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

src/main/kotlin/file/SetupApp.kt

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ object SetupApp {
107107

108108
private fun handleCMD() {
109109
// Cold-start lever: only spend network round-trips and a compiler subprocess on commands
110-
// that actually consult the installation. help/generate stay fully offline and fast.
110+
// that actually consult the installation. help/generate avoid installation checks and stay fast.
111111
when {
112112
setup.command == CLICommand.INSTALL && setup.commandArg.equals("wurstscript", ignoreCase = true) -> {
113113
// Needs to know whether a newer compiler is available online.
@@ -756,9 +756,10 @@ object SetupApp {
756756
useInteractiveMenus: Boolean,
757757
currentPatch: String?
758758
): String {
759-
val versions = CoreJassProvider.fetchJassHistoryVersions()
760-
val recommended = CoreJassProvider.recommendedPatchOptions(versions)
759+
val bundledVersions = CoreJassProvider.supportedPatches
760+
val recommended = CoreJassProvider.recommendedPatchOptions(bundledVersions)
761761
val patchTargets = CoreJassProvider.supportedPatches
762+
val exactVersions by lazy { CoreJassProvider.fetchJassHistoryVersions() }
762763
val normalizedCurrentPatch = currentPatch?.let(CoreJassProvider::normalizePatchInput)
763764
val defaultPatch = when {
764765
normalizedCurrentPatch != null && CoreJassProvider.isSupportedPatch(normalizedCurrentPatch) -> normalizedCurrentPatch
@@ -780,7 +781,7 @@ object SetupApp {
780781
when {
781782
selection == null -> return defaultPatch
782783
selection == browseAll -> browsePatchVersionsInteractive("WC3 patch targets", patchTargets)?.let { return it }
783-
selection == "__browse_exact__" -> browsePatchVersionsInteractive("Exact jass-history dumps", versions)?.let { return it }
784+
selection == "__browse_exact__" -> browsePatchVersionsInteractive("Exact jass-history dumps", exactVersions)?.let { return it }
784785
else -> return selection
785786
}
786787
}
@@ -794,9 +795,7 @@ object SetupApp {
794795
if (patchTargets.isNotEmpty()) {
795796
log.info("Type `more` to browse supported patch targets.")
796797
}
797-
if (versions.isNotEmpty()) {
798-
log.info("Type `exact` to browse raw jass-history dump folders.")
799-
}
798+
log.info("Type `exact` to browse raw jass-history dump folders.")
800799
log.info("Enter a listed number, press Enter for the default, or type `more`.")
801800

802801
while (true) {
@@ -813,11 +812,11 @@ object SetupApp {
813812
title = "WC3 patch targets",
814813
versions = patchTargets,
815814
prompt = prompt,
816-
exactVersions = versions
815+
exactVersions = emptyList()
817816
)?.let { return it }
818817
"exact", "raw", "dumps" -> browsePatchVersions(
819818
title = "Exact jass-history dumps",
820-
versions = versions,
819+
versions = exactVersions,
821820
prompt = prompt,
822821
exactVersions = emptyList()
823822
)?.let { return it }

0 commit comments

Comments
 (0)