Просмотр исходного кода

Better syntax for sorted files

onevcat 10 лет назад
Родитель
Сommit
4340b77ba7
1 измененных файлов с 6 добавлено и 6 удалено
  1. 6 6
      Kingfisher/ImageCache.swift

+ 6 - 6
Kingfisher/ImageCache.swift

@@ -452,16 +452,16 @@ extension ImageCache {
                 let targetSize = self.maxDiskCacheSize / 2
                 let targetSize = self.maxDiskCacheSize / 2
                     
                     
                 // Sort files by last modify date. We want to clean from the oldest files.
                 // Sort files by last modify date. We want to clean from the oldest files.
-                let sortedFiles = cachedFiles.keysSortedByValue({ (resourceValue1, resourceValue2) -> Bool in
+                let sortedFiles = cachedFiles.keysSortedByValue {
+                    resourceValue1, resourceValue2 -> Bool in
                     
                     
-                    if let date1 = resourceValue1[NSURLContentModificationDateKey] as? NSDate {
-                        if let date2 = resourceValue2[NSURLContentModificationDateKey] as? NSDate {
-                            return date1.compare(date2) == .OrderedAscending
-                        }
+                    if let date1 = resourceValue1[NSURLContentModificationDateKey] as? NSDate,
+                           date2 = resourceValue2[NSURLContentModificationDateKey] as? NSDate {
+                        return date1.compare(date2) == .OrderedAscending
                     }
                     }
                     // Not valid date information. This should not happen. Just in case.
                     // Not valid date information. This should not happen. Just in case.
                     return true
                     return true
-                })
+                }
                 
                 
                 for fileURL in sortedFiles {
                 for fileURL in sortedFiles {