• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

gitリポジトリのurlを貼り付けるだけでアプリケーションのビルドを実行するアプリ。 macOS用


Commit MetaInfo

Revision50e05b5cd9e2721684c97f658da433cf32e992c1 (tree)
Zeit2017-08-13 13:54:47
Autormasakih <masakih@user...>
Commitermasakih

Log Message

処理を効率化

Ändern Zusammenfassung

Diff

--- a/AppBuilderWithGit/ProjectFinder.swift
+++ b/AppBuilderWithGit/ProjectFinder.swift
@@ -16,34 +16,31 @@ final class ProjectFinder {
1616 guard depth != 0 else { return nil }
1717
1818 guard let contents = try? FileManager.default.contentsOfDirectory(at: url,
19- includingPropertiesForKeys: [.isDirectoryKey])
19+ includingPropertiesForKeys: [.isDirectoryKey])
2020 else {
2121 return nil
2222 }
2323
24- if let url = contents.filter({ $0.pathExtension == "xcworkspace" }).first {
24+ if let url = contents.lazy.filter({ $0.pathExtension == "xcworkspace" }).first {
2525
2626 return url
2727 }
2828
29- if let url = contents.filter({ $0.pathExtension == "xcodeproj" }).first {
29+ if let url = contents.lazy.filter({ $0.pathExtension == "xcodeproj" }).first {
3030
3131 return url
3232 }
3333
3434
35- let dirs = contents.filter {
36- let att = try? $0.resourceValues(forKeys: [.isDirectoryKey])
37- return att?.isDirectory ?? false
38- }
39- for d in dirs {
35+ func isDir(_ url: URL) -> Bool {
4036
41- if let u = find(in: d, depth: depth - 1) {
42-
43- return u
44- }
37+ return (try? url.resourceValues(forKeys: [.isDirectoryKey]))?.isDirectory ?? false
4538 }
4639
47- return nil
40+ return contents.lazy
41+ .filter(isDir)
42+ .flatMap { find(in: $0, depth: depth - 1) }
43+ .first
44+
4845 }
4946 }