diff options
author | Daniel Gnoutcheff <gnoutchd@softwarefreedom.org> | 2021-09-15 13:59:09 -0400 |
---|---|---|
committer | Daniel Gnoutcheff <gnoutchd@softwarefreedom.org> | 2021-09-15 14:02:21 -0400 |
commit | 874e4951213d6ff8d08eeab15ee80c59fdbe318f (patch) | |
tree | 507e0b83060ee5642dd577c15413915f3b05f198 /app | |
parent | e0029580b656a73f5804929880009fcdc8c03721 (diff) |
Fix memory leak, again
Diffstat (limited to 'app')
-rw-r--r-- | app/Main.hs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/app/Main.hs b/app/Main.hs index b667aa4..9da65af 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -85,8 +85,11 @@ rpcHtmlize args = XRI.renderResponse . XRI.Return . XRI.ValueString . htmlize $ mdwn where Just (XR.Value_AString (XR.AString mdwn)) = lookup "content" args +-- The 'mdwn' binding is mandatory. If we write this function point-free, GHC +-- floats the 'P.readMarkdown readOpts' into a CAF, and for some reason that +-- leaks memory like crazy. htmlize :: String -> String -htmlize = either (error . show) T.unpack . P.runPure . +htmlize mdwn = either (error . show) T.unpack . P.runPure . (P.writeHtml5String P.def =<<) . P.readMarkdown readOpts . T.pack . - filter (\c -> c `elem` "\t\n\r" || (c>=' ' && c/='\x7f')) + filter (\c -> c `elem` "\t\n\r" || (c>=' ' && c/='\x7f')) $ mdwn where readOpts = P.def {P.readerExtensions = P.pandocExtensions} |