From ace07426755b8f0db27c940abe879cbf8165dd60 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Sun, 4 Jun 2023 14:11:47 -0700 Subject: [PATCH] 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. --- Sources/Foundation/FileManager+Win32.swift | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Sources/Foundation/FileManager+Win32.swift b/Sources/Foundation/FileManager+Win32.swift index d708fb86e5..48c5acd36a 100644 --- a/Sources/Foundation/FileManager+Win32.swift +++ b/Sources/Foundation/FileManager+Win32.swift @@ -944,13 +944,10 @@ extension FileManager { func firstValidItem() -> URL? { while let url = _stack.popLast() { if !FileManager.default.fileExists(atPath: url.path) { - if let handler = _errorHandler { + guard let handler = _errorHandler else { return nil } if !handler(url, _NSErrorWithWindowsError(GetLastError(), reading: true, paths: [url.path])) { - return nil + return nil } - } else { - return nil - } } _lastReturned = url return _lastReturned