From e3c55507cf52e697b9ce9d59decc1cbe4cfe5b43 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Wed, 4 Oct 2023 04:08:27 +0200 Subject: [PATCH] perf: Do not check, if the options file exists twice --- src/main/kotlin/app/revanced/cli/command/OptionsCommand.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/app/revanced/cli/command/OptionsCommand.kt b/src/main/kotlin/app/revanced/cli/command/OptionsCommand.kt index d73afe7..82ca026 100644 --- a/src/main/kotlin/app/revanced/cli/command/OptionsCommand.kt +++ b/src/main/kotlin/app/revanced/cli/command/OptionsCommand.kt @@ -39,8 +39,9 @@ internal object OptionsCommand : Runnable { override fun run() = try { PatchBundleLoader.Jar(*patchBundles).let { patches -> - if (!filePath.exists() || overwrite) { - if (update && filePath.exists()) patches.setOptions(filePath) + val exists = filePath.exists() + if (!exists || overwrite) { + if (exists && update) patches.setOptions(filePath) Options.serialize(patches, prettyPrint = true).let(filePath::writeText) } else throw OptionsFileAlreadyExistsException()