read: only run finalise twice if there are modifiers

Previously we ran if `--auto` was set. But this adds a small
performance hit if `--auto` becomes default. Now we only run twice if
there are transactionModifiers AND `--auto` is set. So even if auto is
specified, there will be no penalty if there are no modifiers.
This commit is contained in:
Jesse Rosenthal 2018-10-12 08:51:53 -04:00 committed by Simon Michael
parent 6c3fb56603
commit 20f134c96b

View File

@ -264,7 +264,7 @@ parseAndFinaliseJournal parser iopts f txt = do
-- the options for checking assertions.
let runFin :: Bool -> Bool -> (ParsedJournal -> Either String Journal)
runFin reorder ignore = journalFinalise t f txt reorder ignore
fj = if auto_ iopts
fj = if auto_ iopts && (not . null . jtxnmodifiers) pj
then applyTransactionModifiers <$>
runFin True False pj >>=
runFin False (not $ ignore_assertions_ iopts)
@ -295,7 +295,7 @@ parseAndFinaliseJournal' parser iopts f txt = do
-- options for checking assertions.
let runFin :: Bool -> Bool -> (ParsedJournal -> Either String Journal)
runFin reorder ignore = journalFinalise t f txt reorder ignore
fj = if auto_ iopts
fj = if auto_ iopts && (not . null . jtxnmodifiers) pj
then applyTransactionModifiers <$>
runFin True False pj >>=
runFin False (not $ ignore_assertions_ iopts)