From 122cce3bc7bb8e3674171922d04d3274e38647ee Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sat, 30 Jan 2021 14:15:17 -0500 Subject: [PATCH] Disable blurhashes in debug builds --- Tusker/Vendor/BlurHashDecode.swift | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Tusker/Vendor/BlurHashDecode.swift b/Tusker/Vendor/BlurHashDecode.swift index 9e9f6a6e..fcd1a6a1 100644 --- a/Tusker/Vendor/BlurHashDecode.swift +++ b/Tusker/Vendor/BlurHashDecode.swift @@ -2,9 +2,17 @@ /// From https://github.com/woltapp/blurhash/blob/b23214ddcab803fe1ec9a3e6b20558caf33a23a5/Swift/BlurHashDecode.swift import UIKit +// blurhashes are disabled in debug builds because this code is hideously slow when not optimized by the compiler +#if DEBUG +fileprivate let blurHashesEnabled = ProcessInfo.processInfo.environment.keys.contains("DEBUG_BLUR_HASH") +#else +fileprivate let blurHashesEnabled = true +#endif + extension UIImage { public convenience init?(blurHash: String, size: CGSize, punch: Float = 1) { - guard blurHash.count >= 6 else { return nil } + guard blurHashesEnabled, + blurHash.count >= 6 else { return nil } let sizeFlag = String(blurHash[0]).decode83() let numY = (sizeFlag / 9) + 1