Skip to content

Commit

Permalink
Avoid .unique
Browse files Browse the repository at this point in the history
  • Loading branch information
SimplyDanny committed Nov 20, 2023
1 parent 6806b1b commit 6a0585a
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,17 @@ extension Configuration {
///
/// - returns: The input paths after removing the excluded paths.
public func filterExcludedPaths(in paths: [String]...) -> [String] {
let allPaths = paths.flatMap { $0 }
#if os(Linux)
let result = NSMutableOrderedSet(capacity: allPaths.count)
result.addObjects(from: allPaths)
#else
let result = NSMutableOrderedSet(array: allPaths)
#endif
let exclusionPatterns = self.excludedPaths.map { Glob.createFilenameMatcher(root: rootDirectory, pattern: $0) }
let pathsWithoutExclusions = paths
.flatMap { $0 }
return result
.map { $0 as! String } // swiftlint:disable:this force_cast
.filter { !exclusionPatterns.anyMatch(filename: $0) }
return pathsWithoutExclusions.unique
}

/// Returns the file paths that are excluded by this configuration using filtering by absolute path prefix.
Expand Down

0 comments on commit 6a0585a

Please sign in to comment.