on master help sign in
Speed up hashing in cache
commite2db1b21dde1dd0227670b6d84fab3b57411292e author0xd34df00d <0xd34df00d@gmail.com> dateSun 28 Oct 2018, 08:54 (8 years ago) parent6b5010b
1 file changed+6−2
lib/Hakyll/Core/Store.hs+6−2
lib/Hakyll/Core/Store.hs+6−2
@@ -27,6 +27,7 @@ import Data.Maybe (isJust)
2727import qualified Data.Text as T
2828import qualified Data.Text.Encoding as T
2929import Data.Typeable (TypeRep, Typeable, cast, typeOf)
30+import Numeric (showHex)
3031import System.Directory (createDirectoryIfMissing)
3132import System.Directory (doesFileExist, removeFile)
3233import System.FilePath ((</>))
@@ -193,5 +194,8 @@ deleteFile = handle (\(_ :: IOException) -> return ()) . removeFile
193194--------------------------------------------------------------------------------
194195-- | Mostly meant for internal usage
195196hash :: [String] -> String
196−hash = concatMap (printf "%02x") . B.unpack .
197− MD5.hash . T.encodeUtf8 . T.pack . intercalate "/"
197+hash = toHex . B.unpack . MD5.hash . T.encodeUtf8 . T.pack . intercalate "/"
198+ where
199+ toHex [] = ""
200+ toHex (x : xs) | x < 16 = '0' : showHex x (toHex xs)
201+ | otherwise = showHex x (toHex xs)