Speed up SettingsBuilder (#1221)

* Speed up SettingsBuilder

It's unnecessary to build up a whole grouped dictionary only to check
if all platforms are identical and then immediately discard the
dictionary.

Instead we can check if all targets match the first platform, which
avoids creating a new dictionary but also allows bailing early as soon
as a non-matching platform is found.

Generating a large project (36MB json spec) on an M1 Max machine leads
to a ~6% total speedup: 28.48s vs 30.07s.

* Add changelog entry
This commit is contained in:
JP Simard
2022-06-16 13:54:28 +10:00
committed by GitHub
parent a2348d0cfa
commit f65dad7625
2 changed files with 9 additions and 7 deletions
+5 -7
View File
@@ -11,12 +11,10 @@ extension Project {
var buildSettings: BuildSettings = [:]
// set project SDKROOT is a single platform
if targets.count > 0 {
let platforms = Dictionary(grouping: targets) { $0.platform }
if platforms.count == 1 {
let platform = platforms.first!.key
buildSettings["SDKROOT"] = platform.sdkRoot
}
if let firstPlatform = targets.first?.platform,
targets.allSatisfy({ $0.platform == firstPlatform })
{
buildSettings["SDKROOT"] = firstPlatform.sdkRoot
}
if let type = config.type, options.settingPresets.applyProject {
@@ -31,7 +29,7 @@ extension Project {
}
}
// Prevent setting presets from overrwriting settings in project xcconfig files
// Prevent setting presets from overwriting settings in project xcconfig files
if let configPath = configFiles[config.name] {
buildSettings = removeConfigFileSettings(from: buildSettings, configPath: configPath)
}