Browse Source

Some minor improvement for building time

onevcat 6 years ago
parent
commit
0afb81e57d

+ 4 - 4
Sources/General/KingfisherOptionsInfo.swift

@@ -347,13 +347,13 @@ class ImageLoadingProgressSideEffect: DataReceivingSideEffect {
     func onDataReceived(_ session: URLSession, task: SessionDataTask, data: Data) {
         DispatchQueue.main.async {
             guard self.onShouldApply() else { return }
-            guard
-                let expectedContentLength = task.task.response?.expectedContentLength,
-                expectedContentLength != -1 else {
+            guard let expectedContentLength = task.task.response?.expectedContentLength,
+                      expectedContentLength != -1 else
+            {
                 return
             }
 
-            let dataLength = Int64(task.mutableData.count)
+            let dataLength: Int64 = Int64(task.mutableData.count)
             self.block(dataLength, expectedContentLength)
         }
     }

+ 2 - 2
Sources/Image/ImageDrawing.swift

@@ -254,12 +254,12 @@ extension KingfisherWrapper where Base: KFCrossPlatformImage {
         // http://www.w3.org/TR/SVG/filters.html#feGaussianBlurElement
         // let d = floor(s * 3*sqrt(2*pi)/4 + 0.5)
         // if d is odd, use three box-blurs of size 'd', centered on the output pixel.
-        let s = Float(max(radius, 2.0))
+        let s = max(radius, 2.0)
         // We will do blur on a resized image (*0.5), so the blur radius could be half as well.
         
         // Fix the slow compiling time for Swift 3.
         // See https://github.com/onevcat/Kingfisher/issues/611
-        let pi2 = 2 * Float.pi
+        let pi2 = 2 * CGFloat.pi
         let sqrtPi2 = sqrt(pi2)
         var targetRadius = floor(s * 3.0 * sqrtPi2 / 4.0 + 0.5)
         

+ 1 - 1
Sources/Utility/ExtensionHelpers.swift

@@ -26,7 +26,7 @@
 
 import Foundation
 
-extension Float {
+extension CGFloat {
     var isEven: Bool {
         return truncatingRemainder(dividingBy: 2.0) == 0
     }

+ 3 - 2
Sources/Views/AnimatedImageView.swift

@@ -294,11 +294,12 @@ open class AnimatedImageView: UIImageView {
         // See [#718](https://github.com/onevcat/Kingfisher/issues/718)
         // By setting CADisableMinimumFrameDuration to YES in Info.plist may
         // cause the preferredFramesPerSecond being 0
-        if displayLink.preferredFramesPerSecond == 0 {
+        let preferredFramesPerSecond = displayLink.preferredFramesPerSecond
+        if preferredFramesPerSecond == 0 {
             duration = displayLink.duration
         } else {
             // Some devices (like iPad Pro 10.5) will have a different FPS.
-            duration = 1.0 / Double(displayLink.preferredFramesPerSecond)
+            duration = 1.0 / Double(preferredFramesPerSecond)
         }
 
         animator.shouldChangeFrame(with: duration) { [weak self] hasNewFrame in