From e2db1b21dde1dd0227670b6d84fab3b57411292e Mon Sep 17 00:00:00 2001 From: 0xd34df00d <0xd34df00d@gmail.com> Date: Sun, 28 Oct 2018 08:54:19 -0400 Subject: Speed up hashing in cache --- lib/Hakyll/Core/Store.hs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/Hakyll/Core/Store.hs b/lib/Hakyll/Core/Store.hs index fdbcf11..cb17218 100644 --- a/lib/Hakyll/Core/Store.hs +++ b/lib/Hakyll/Core/Store.hs @@ -27,6 +27,7 @@ import Data.Maybe (isJust) import qualified Data.Text as T import qualified Data.Text.Encoding as T import Data.Typeable (TypeRep, Typeable, cast, typeOf) +import Numeric (showHex) import System.Directory (createDirectoryIfMissing) import System.Directory (doesFileExist, removeFile) import System.FilePath (()) @@ -193,5 +194,8 @@ deleteFile = handle (\(_ :: IOException) -> return ()) . removeFile -------------------------------------------------------------------------------- -- | Mostly meant for internal usage hash :: [String] -> String -hash = concatMap (printf "%02x") . B.unpack . - MD5.hash . T.encodeUtf8 . T.pack . intercalate "/" +hash = toHex . B.unpack . MD5.hash . T.encodeUtf8 . T.pack . intercalate "/" + where + toHex [] = "" + toHex (x : xs) | x < 16 = '0' : showHex x (toHex xs) + | otherwise = showHex x (toHex xs) -- cgit v1.2.3