diff options
author | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2010-01-24 11:31:36 +0100 |
---|---|---|
committer | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2010-01-24 11:31:36 +0100 |
commit | 4295de01bc524b5dccb17dfe2e50f2121feeea07 (patch) | |
tree | 1faffd2eeae3b907bfd130bb765368d8eb181b42 /src/Text/Hakyll/Page.hs | |
parent | 59e3c7f277a64f09ef65c4ca42d7c2398f04acd4 (diff) | |
download | hakyll-4295de01bc524b5dccb17dfe2e50f2121feeea07.tar.gz |
Added tagMap caching.
Because the readTagMap function was currently one of the bottlenexks, this has
caused a speedup of 900% for some test cases, so yay for that.
Diffstat (limited to 'src/Text/Hakyll/Page.hs')
-rw-r--r-- | src/Text/Hakyll/Page.hs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/Text/Hakyll/Page.hs b/src/Text/Hakyll/Page.hs index abfd0b8..b9507b6 100644 --- a/src/Text/Hakyll/Page.hs +++ b/src/Text/Hakyll/Page.hs @@ -120,7 +120,7 @@ readPageFromFile path = do -- Read file. contents <- liftIO $ readFile path - let sections = splitAtDelimiters $ lines $ contents + let sections = splitAtDelimiters $ lines contents context = concat $ zipWith ($) sectionFunctions sections page = fromContext $ M.fromList $ [ ("url", url) @@ -135,11 +135,11 @@ readPageFromFile path = do -- read it from the file given and store it in the cache. readPage :: FilePath -> Hakyll Page readPage path = do - cacheResult <- getFromCache path - case cacheResult of (Just page) -> return page - Nothing -> do page <- readPageFromFile path - storeInCache page path - return page + isCacheMoreRecent' <- isCacheMoreRecent path [path] + if isCacheMoreRecent' then getFromCache path + else do page <- readPageFromFile path + storeInCache page path + return page -- Make pages renderable. instance Renderable Page where |