Skip to content

Commit

Permalink
Cache slow operations
Browse files Browse the repository at this point in the history
  • Loading branch information
dz0ny committed Oct 22, 2024
1 parent 814ec21 commit 6cacccb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions Pareto/Extensions/SSHCheck.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,17 @@ class SSHCheck: ParetoCheck {
let sshPath = FileManager.default.homeDirectoryForCurrentUser.appendingPathComponent(".ssh").resolvingSymlinksInPath()
private var sshKeygenPath = ""

private var itExistsCache = [String: Bool]()

func itExists(_ path: String) -> Bool {
FileManager.default.fileExists(atPath: path)
if let cachedResult = itExistsCache[path] {
return cachedResult
}
let exists = FileManager.default.fileExists(atPath: path)
itExistsCache[path] = exists
return exists
}

func getSSHKeygenPath() -> String {
if !sshKeygenPath.isEmpty {
return sshKeygenPath
Expand Down
2 changes: 1 addition & 1 deletion Pareto/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>5482</string>
<string>5483</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSMinimumSystemVersion</key>
Expand Down

0 comments on commit 6cacccb

Please sign in to comment.