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

Merge pull request #613 from onevcat/fix/slow-compiling-blur

Faster compiling time for blur
Wei Wang 9 лет назад
Родитель
Сommit
da12027e3a
1 измененных файлов с 6 добавлено и 1 удалено
  1. 6 1
      Sources/Image.swift

+ 6 - 1
Sources/Image.swift

@@ -453,7 +453,12 @@ extension Kingfisher where Base: Image {
             // if d is odd, use three box-blurs of size 'd', centered on the output pixel.
             let s = Float(max(radius, 2.0))
             // We will do blur on a resized image (*0.5), so the blur radius could be half as well.
-            var targetRadius = floor(s * 3.0 * sqrt(2 * Float.pi) / 4.0 + 0.5)
+            
+            // Fix the slow compiling time for Swift 3. 
+            // See https://github.com/onevcat/Kingfisher/issues/611
+            let pi2 = 2 * Float.pi
+            let sqrtPi2 = sqrt(pi2)
+            var targetRadius = floor(s * 3.0 * sqrtPi2 / 4.0 + 0.5)
             
             if targetRadius.isEven {
                 targetRadius += 1