Skip to content

Commit 9067cce

Browse files
committed
Foundation: simplify handler handling
Reduce the conditional logic by unwrapping the handler rather than adding conditional case. This should make it easier to perform a series of refactorings.
1 parent 11b0dbc commit 9067cce

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

Sources/Foundation/FileManager+Win32.swift

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -944,13 +944,10 @@ extension FileManager {
944944
func firstValidItem() -> URL? {
945945
while let url = _stack.popLast() {
946946
if !FileManager.default.fileExists(atPath: url.path) {
947-
if let handler = _errorHandler {
947+
guard let handler = _errorHandler else { return nil }
948948
if !handler(url, _NSErrorWithWindowsError(GetLastError(), reading: true, paths: [url.path])) {
949-
return nil
949+
return nil
950950
}
951-
} else {
952-
return nil
953-
}
954951
}
955952
_lastReturned = url
956953
return _lastReturned

0 commit comments

Comments
 (0)