Skip to content

Commit 9079c94

Browse files
committed
Refactor HTTPCookieStorage.sortedCookies using the return value of DispatchQueue.sync
1 parent c5357f3 commit 9079c94

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

Foundation/HTTPCookieStorage.swift

+2-4
Original file line numberDiff line numberDiff line change
@@ -337,12 +337,10 @@ open class HTTPCookieStorage: NSObject {
337337
@discussion proper sorting of cookies may require extensive string conversion, which can be avoided by allowing the system to perform the sorting. This API is to be preferred over the more generic -[HTTPCookieStorage cookies] API, if sorting is going to be performed.
338338
*/
339339
open func sortedCookies(using sortOrder: [NSSortDescriptor]) -> [HTTPCookie] {
340-
var result: [HTTPCookie] = []
341-
syncQ.sync {
340+
return syncQ.sync {
342341
let cookies = Array(allCookies.values) as NSArray
343-
result = cookies.sortedArray(using: sortOrder) as! [HTTPCookie]
342+
return cookies.sortedArray(using: sortOrder) as! [HTTPCookie]
344343
}
345-
return result
346344
}
347345
}
348346

0 commit comments

Comments
 (0)