Optimize simplifying paths for faster project generation (#857)

This commit is contained in:
Akio Yasui
2020-05-12 10:28:49 -05:00
committed by GitHub
parent 4d6e63e880
commit 2ed9a81d81
2 changed files with 9 additions and 1 deletions
+1
View File
@@ -26,6 +26,7 @@
- Fix linking of multiple products from the same Swift Package [#830](https://github.com/yonaskolb/XcodeGen/pull/830) @toshi0383
- Don't deduplicate files in `include` with different path but same name. [#849](https://github.com/yonaskolb/XcodeGen/pull/849) @akkyie
- Don't link transitive static carthage libraries. [#853](https://github.com/yonaskolb/XcodeGen/pull/853) @akkyie
- Optimize simplifying paths for faster project generation. [#857](https://github.com/yonaskolb/XcodeGen/pull/857) @akkyie
## 2.15.1
+8 -1
View File
@@ -11,7 +11,14 @@ extension Path {
/// - `../a/b` simplifies to `../a/b`
/// - `a/../../c` simplifies to `../c`
public func simplifyingParentDirectoryReferences() -> Path {
normalize().components.reduce(Path(), +)
if !string.contains("..") { // Skip simplifying if its already simple
var string = self.string
while string.hasSuffix(Path.separator) { // Remove all trailing path separators
string.removeLast()
}
return Path(String(string))
}
return normalize().components.reduce(Path(), +)
}
/// Returns the relative path necessary to go from `base` to `self`.