This commit is contained in:
Kotov Max 2024-06-07 10:09:24 -07:00 committed by GitHub
commit 1ade0746f6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 39 additions and 14 deletions

View File

@ -0,0 +1,37 @@
import XcodeProj
import Foundation
enum Cached<T> {
case cached(T)
case nothing
var value: T? {
switch self {
case let .cached(value): return value
case .nothing: return nil
}
}
}
final class CacheContainer {
let value: Cached<BuildSettings>
init(value: Cached<BuildSettings>) {
self.value = value
}
}
extension NSCache where KeyType == NSString, ObjectType == CacheContainer {
subscript(aKey: String) -> Cached<BuildSettings>? {
get {
object(forKey: aKey as NSString)?.value
}
set {
if let value = newValue {
setObject(CacheContainer(value: value), forKey: aKey as NSString)
} else {
removeObject(forKey: aKey as NSString)
}
}
}
}

View File

@ -207,23 +207,11 @@ extension Project {
}
}
private enum Cached<T> {
case cached(T)
case nothing
var value: T? {
switch self {
case let .cached(value): return value
case .nothing: return nil
}
}
}
// cached flattened xcconfig file settings
private var configFileSettings: [String: Cached<BuildSettings>] = [:]
private var configFileSettings = NSCache<NSString, CacheContainer>()
// cached setting preset settings
private var settingPresetSettings: [String: Cached<BuildSettings>] = [:]
private var settingPresetSettings = NSCache<NSString, CacheContainer>()
extension SettingsPresetFile {