summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author0xd34df00d <0xd34df00d@gmail.com>2018-10-28 08:54:19 -0400
committerJasper Van der Jeugt <jaspervdj@gmail.com>2018-10-28 12:54:19 +0000
commite2db1b21dde1dd0227670b6d84fab3b57411292e (patch)
tree4367425e0016fb000642045716cd97bdfc7103a4
parent6b5010b38eec92168f62fa4b1b296bae12f14f21 (diff)
downloadhakyll-e2db1b21dde1dd0227670b6d84fab3b57411292e.tar.gz
Speed up hashing in cache
-rw-r--r--lib/Hakyll/Core/Store.hs8
1 files changed, 6 insertions, 2 deletions
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)