Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Split out strictifyChunk

  • Loading branch information...
commit 13b28afca48c8cb2c1ce08ae1b381c07076ec414 1 parent 32c4f89
@mightybyte mightybyte authored
View
10 src/Heist/Compiled/Internal.hs
@@ -221,12 +221,16 @@ compileTemplate :: Monad n
-> IO [Chunk n]
compileTemplate hs tpath df = do
!chunks <- runSplice nullNode hs $! runDocumentFile tpath df
- return $! map strictify chunks
+ return $! map strictifyChunk chunks
where
-- This gets overwritten in runDocumentFile
nullNode = X.TextNode ""
- strictify (Pure b) = Pure $! fromByteString $! toByteString b
- strictify c = c
+
+
+strictifyChunk :: Monad m => Chunk m -> Chunk m
+strictifyChunk (Pure b) = Pure $! fromByteString $! toByteString b
+strictifyChunk !c = c
+{-# INLINE strictifyChunk #-}
------------------------------------------------------------------------------
View
1  src/Heist/Types.hs
@@ -119,6 +119,7 @@ isPureChunk :: Chunk m -> Bool
isPureChunk (Pure _) = True
isPureChunk _ = False
+
------------------------------------------------------------------------------
-- | Type alias for attribute splices. The function parameter is the value of
-- the bound attribute splice. The return value is a list of attribute
View
4 test/suite/Benchmark.hs
@@ -39,7 +39,7 @@ loadWithCache baseDir = do
main = do
let page = "faq"
pageStr = T.unpack $ decodeUtf8 page
- dir = "snap-website"
+ dir = "snap-website-nocache"
hs <- loadWithCache dir
let !compiledTemplate = fst $! fromJust $! C.renderTemplate hs page
compiledAction = do
@@ -48,7 +48,7 @@ main = do
out <- compiledAction
B.writeFile (pageStr++".out.compiled."++dir) $ out
putStrLn "Templates loaded"
- replicateM_ 10000 $ whnfIO compiledAction
+ replicateM_ 1000000 $ whnfIO compiledAction
putStrLn "done"
justRender dir = do
Please sign in to comment.
Something went wrong with that request. Please try again.