From 681e320867ef43ff23b4dcf2bf277c832f5b00cb Mon Sep 17 00:00:00 2001 From: Zewu Chen <39866572+zewuchen@users.noreply.github.com> Date: Sun, 29 Dec 2024 01:19:06 -0300 Subject: [PATCH] Add improvement of performance in SpecValidation on validateSettings (#1522) --- Sources/ProjectSpec/SpecValidation.swift | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Sources/ProjectSpec/SpecValidation.swift b/Sources/ProjectSpec/SpecValidation.swift index a34fb3d4..3cb9d8aa 100644 --- a/Sources/ProjectSpec/SpecValidation.swift +++ b/Sources/ProjectSpec/SpecValidation.swift @@ -17,27 +17,30 @@ extension Project { errors.append(.invalidSettingsGroup(group)) } } + for config in settings.configSettings.keys { - if !configs.contains(where: { $0.name.lowercased().contains(config.lowercased()) }) { - if !options.disabledValidations.contains(.missingConfigs) { - errors.append(.invalidBuildSettingConfig(config)) - } + if !configs.contains(where: { $0.name.lowercased().contains(config.lowercased()) }), + !options.disabledValidations.contains(.missingConfigs) { + errors.append(.invalidBuildSettingConfig(config)) } } if settings.buildSettings.count == configs.count { var allConfigs = true - for buildSetting in settings.buildSettings.keys { + outerLoop: for buildSetting in settings.buildSettings.keys { var isConfig = false for config in configs { if config.name.lowercased().contains(buildSetting.lowercased()) { isConfig = true + break } } if !isConfig { allConfigs = false + break outerLoop } } + if allConfigs { errors.append(.invalidPerConfigSettings) }