@@ -92,7 +92,7 @@ class Frontend {
92
92
if paths. isEmpty {
93
93
processStandardInput ( )
94
94
} else {
95
- processPaths ( paths)
95
+ processPaths ( paths, parallel : lintFormatOptions . parallel )
96
96
}
97
97
}
98
98
@@ -124,28 +124,41 @@ class Frontend {
124
124
}
125
125
126
126
/// Processes source content from a list of files and/or directories provided as paths.
127
- private func processPaths( _ paths: [ String ] ) {
127
+ private func processPaths( _ paths: [ String ] , parallel : Bool ) {
128
128
precondition (
129
129
!paths. isEmpty,
130
130
" processPaths(_:) should only be called when paths is non-empty. " )
131
131
132
- for path in FileIterator ( paths: paths) {
133
- guard let sourceFile = FileHandle ( forReadingAtPath: path) else {
134
- diagnosticEngine. diagnose ( Diagnostic . Message ( . error, " Unable to open \( path) " ) )
135
- continue
132
+ if parallel {
133
+ let allFilePaths = Array ( FileIterator ( paths: paths) )
134
+ DispatchQueue . concurrentPerform ( iterations: allFilePaths. count) { index in
135
+ let path = allFilePaths [ index]
136
+ openAndProcess ( path)
136
137
}
137
-
138
- guard let configuration = configuration (
139
- atPath: lintFormatOptions. configurationPath, orInferredFromSwiftFileAtPath: path)
140
- else {
141
- // Already diagnosed in the called method.
142
- continue
138
+ } else {
139
+ for path in FileIterator ( paths: paths) {
140
+ openAndProcess ( path)
143
141
}
142
+ }
143
+ }
144
+
145
+ /// Read and process the given path, optionally synchronizing diagnostic output.
146
+ private func openAndProcess( _ path: String ) -> Void {
147
+ guard let sourceFile = FileHandle ( forReadingAtPath: path) else {
148
+ diagnosticEngine. diagnose ( Diagnostic . Message ( . error, " Unable to open \( path) " ) )
149
+ return
150
+ }
144
151
145
- let fileToProcess = FileToProcess (
146
- fileHandle: sourceFile, path: path, configuration: configuration)
147
- processFile ( fileToProcess)
152
+ guard let configuration = configuration (
153
+ atPath: lintFormatOptions. configurationPath, orInferredFromSwiftFileAtPath: path)
154
+ else {
155
+ // Already diagnosed in the called method.
156
+ return
148
157
}
158
+
159
+ let fileToProcess = FileToProcess (
160
+ fileHandle: sourceFile, path: path, configuration: configuration)
161
+ processFile ( fileToProcess)
149
162
}
150
163
151
164
/// Returns the configuration that applies to the given `.swift` source file, when an explicit
0 commit comments