mirror of
https://github.com/realm/SwiftLint.git
synced 2026-06-06 20:18:40 +00:00
Improve performance of excluded files filter (#5157)
The current algorithm is like "collect all included files and subtract all excluded files". Collecting all included and all excluded files relies on the file system. This can become slow when the patterns used to exclude files resolve to a large number of files. The new approach only collects all lintable files and checks them against the exclude patterns. This can be done by in-memory string-regex-match and does therefore not require file system accesses.
This commit is contained in:
@@ -68,11 +68,20 @@ public extension String {
|
||||
|
||||
/// Returns a new string, converting the path to a canonical absolute path.
|
||||
///
|
||||
/// > Important: This method might use an incorrect working directory internally. This can cause test failures
|
||||
/// in Bazel builds but does not seem to cause trouble in production.
|
||||
///
|
||||
/// - returns: A new `String`.
|
||||
func absolutePathStandardized() -> String {
|
||||
bridge().absolutePathRepresentation().bridge().standardizingPath
|
||||
}
|
||||
|
||||
/// Like ``absolutePathStandardized()`` but with the working directory that's used everywhere else.
|
||||
var normalized: String {
|
||||
let cwd = FileManager.default.currentDirectoryPath.bridge().standardizingPath
|
||||
return bridge().absolutePathRepresentation(rootDirectory: cwd)
|
||||
}
|
||||
|
||||
var isFile: Bool {
|
||||
if self.isEmpty {
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user