From 314a4c7296029753872164428667c63642762901 Mon Sep 17 00:00:00 2001 From: Jesse Rosenthal Date: Sat, 19 Nov 2016 05:57:33 -0500 Subject: Remove readFileStrict. We only used it once, and then immediately converted to lazy. --- src/Text/Pandoc/Free.hs | 13 +------------ src/Text/Pandoc/Writers/Docx.hs | 2 +- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/src/Text/Pandoc/Free.hs b/src/Text/Pandoc/Free.hs index 071482e32..4294384d4 100644 --- a/src/Text/Pandoc/Free.hs +++ b/src/Text/Pandoc/Free.hs @@ -45,7 +45,6 @@ module Text.Pandoc.Free ( PandocActionF(..) , getDefaultReferenceODT , newStdGen , newUniqueHash - , readFileStrict , readFileLazy , readFileUTF8 , readDataFile @@ -97,7 +96,6 @@ data PandocActionF nxt = | GetDefaultReferenceODT (Maybe FilePath) (Archive -> nxt) | NewStdGen (StdGen -> nxt) | NewUniqueHash (Int -> nxt) - | ReadFileStrict FilePath (B.ByteString -> nxt) | ReadFileLazy FilePath (BL.ByteString -> nxt) | ReadFileUTF8 FilePath (String -> nxt) | ReadDataFile (Maybe FilePath) FilePath (B.ByteString -> nxt) @@ -133,9 +131,6 @@ newStdGen = liftF $ NewStdGen id newUniqueHash :: PandocAction Int newUniqueHash = liftF $ NewUniqueHash id -readFileStrict :: FilePath -> PandocAction B.ByteString -readFileStrict fp = liftF $ ReadFileStrict fp id - readFileLazy :: FilePath -> PandocAction BL.ByteString readFileLazy fp = liftF $ ReadFileLazy fp id @@ -176,7 +171,6 @@ runIO (Free (GetDefaultReferenceODT mfp f)) = IO.getDefaultReferenceODT mfp >>= runIO . f runIO (Free (NewStdGen f)) = IO.newStdGen >>= runIO . f runIO (Free (NewUniqueHash f)) = hashUnique <$> IO.newUnique >>= runIO . f -runIO (Free (ReadFileStrict fp f)) = B.readFile fp >>= runIO . f runIO (Free (ReadFileLazy fp f)) = BL.readFile fp >>= runIO . f runIO (Free (ReadFileUTF8 fp f)) = UTF8.readFile fp >>= runIO . f runIO (Free (ReadDataFile mfp fp f)) = IO.readDataFile mfp fp >>= runIO . f @@ -242,11 +236,6 @@ runTest (Free (NewUniqueHash f)) = do modify $ \st -> st { stUniqStore = us } return u >>= runTest . f _ -> M.fail "uniq store ran out of elements" -runTest (Free (ReadFileStrict fp f)) = do - fps <- asks envFiles - case lookup fp fps of - Just bs -> return bs >>= runTest . f - Nothing -> error "openFile: does not exist" runTest (Free (ReadFileLazy fp f)) = do fps <- asks envFiles case lookup fp fps of @@ -269,7 +258,7 @@ runTest (Free (ReadDataFile Nothing "reference.odt" f)) = do runTest . f runTest (Free (ReadDataFile Nothing fname f)) = do let fname' = if fname == "MANUAL.txt" then fname else "data" fname - runTest (readFileStrict fname') >>= runTest . f + runTest (BL.toStrict <$> readFileLazy fname') >>= runTest . f runTest (Free (ReadDataFile (Just userDir) fname f)) = do userDirFiles <- asks envUserDataDir case lookup (userDir fname) userDirFiles of diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs index 3f380a3ee..07041f189 100644 --- a/src/Text/Pandoc/Writers/Docx.hs +++ b/src/Text/Pandoc/Writers/Docx.hs @@ -232,7 +232,7 @@ writeDocxPure opts doc@(Pandoc meta _) = do utctime <- P.getCurrentTime distArchive <- P.getDefaultReferenceDocx datadir refArchive <- case writerReferenceDocx opts of - Just f -> liftM (toArchive . toLazy) $ P.readFileStrict f + Just f -> toArchive <$> P.readFileLazy f Nothing -> P.getDefaultReferenceDocx datadir parsedDoc <- parseXml refArchive distArchive "word/document.xml" -- cgit v1.2.3