git.iko.soy/typeable/pandoc
on master help sign in
Remove readFileStrict.

We only used it once, and then immediately converted to lazy.

commit314a4c7296029753872164428667c63642762901 authorJesse Rosenthal <jrosenthal@jhu.edu> dateSat 19 Nov 2016, 05:57 (10 years ago) parentc9e6716
2 files changed+2−13
src/Text/Pandoc/Free.hs+1−12 src/Text/Pandoc/Writers/Docx.hs+1−1
src/Text/Pandoc/Free.hs+1−12
@@ -45,7 +45,6 @@ module Text.Pandoc.Free ( PandocActionF(..)
4545 , getDefaultReferenceODT
4646 , newStdGen
4747 , newUniqueHash
48− , readFileStrict
4948 , readFileLazy
5049 , readFileUTF8
5150 , readDataFile
@@ -97,7 +96,6 @@ data PandocActionF nxt =
9796 | GetDefaultReferenceODT (Maybe FilePath) (Archive -> nxt)
9897 | NewStdGen (StdGen -> nxt)
9998 | NewUniqueHash (Int -> nxt)
100− | ReadFileStrict FilePath (B.ByteString -> nxt)
10199 | ReadFileLazy FilePath (BL.ByteString -> nxt)
102100 | ReadFileUTF8 FilePath (String -> nxt)
103101 | ReadDataFile (Maybe FilePath) FilePath (B.ByteString -> nxt)
@@ -133,9 +131,6 @@ newStdGen = liftF $ NewStdGen id
133131newUniqueHash :: PandocAction Int
134132newUniqueHash = liftF $ NewUniqueHash id
135133
136−readFileStrict :: FilePath -> PandocAction B.ByteString
137−readFileStrict fp = liftF $ ReadFileStrict fp id
138−
139134readFileLazy :: FilePath -> PandocAction BL.ByteString
140135readFileLazy fp = liftF $ ReadFileLazy fp id
141136
@@ -176,7 +171,6 @@ runIO (Free (GetDefaultReferenceODT mfp f)) =
176171 IO.getDefaultReferenceODT mfp >>= runIO . f
177172runIO (Free (NewStdGen f)) = IO.newStdGen >>= runIO . f
178173runIO (Free (NewUniqueHash f)) = hashUnique <$> IO.newUnique >>= runIO . f
179−runIO (Free (ReadFileStrict fp f)) = B.readFile fp >>= runIO . f
180174runIO (Free (ReadFileLazy fp f)) = BL.readFile fp >>= runIO . f
181175runIO (Free (ReadFileUTF8 fp f)) = UTF8.readFile fp >>= runIO . f
182176runIO (Free (ReadDataFile mfp fp f)) = IO.readDataFile mfp fp >>= runIO . f
@@ -242,11 +236,6 @@ runTest (Free (NewUniqueHash f)) = do
242236 modify $ \st -> st { stUniqStore = us }
243237 return u >>= runTest . f
244238 _ -> M.fail "uniq store ran out of elements"
245−runTest (Free (ReadFileStrict fp f)) = do
246− fps <- asks envFiles
247− case lookup fp fps of
248− Just bs -> return bs >>= runTest . f
249− Nothing -> error "openFile: does not exist"
250239runTest (Free (ReadFileLazy fp f)) = do
251240 fps <- asks envFiles
252241 case lookup fp fps of
@@ -269,7 +258,7 @@ runTest (Free (ReadDataFile Nothing "reference.odt" f)) = do
269258 runTest . f
270259runTest (Free (ReadDataFile Nothing fname f)) = do
271260 let fname' = if fname == "MANUAL.txt" then fname else "data" </> fname
272− runTest (readFileStrict fname') >>= runTest . f
261+ runTest (BL.toStrict <$> readFileLazy fname') >>= runTest . f
273262runTest (Free (ReadDataFile (Just userDir) fname f)) = do
274263 userDirFiles <- asks envUserDataDir
275264 case lookup (userDir </> fname) userDirFiles of
src/Text/Pandoc/Writers/Docx.hs+1−1
@@ -232,7 +232,7 @@ writeDocxPure opts doc@(Pandoc meta _) = do
232232 utctime <- P.getCurrentTime
233233 distArchive <- P.getDefaultReferenceDocx datadir
234234 refArchive <- case writerReferenceDocx opts of
235− Just f -> liftM (toArchive . toLazy) $ P.readFileStrict f
235+ Just f -> toArchive <$> P.readFileLazy f
236236 Nothing -> P.getDefaultReferenceDocx datadir
237237
238238 parsedDoc <- parseXml refArchive distArchive "word/document.xml"