From 20f134c96b1aac547ed121a87c401f24758ea73c Mon Sep 17 00:00:00 2001 From: Jesse Rosenthal Date: Fri, 12 Oct 2018 08:51:53 -0400 Subject: [PATCH] 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. --- hledger-lib/Hledger/Read/Common.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hledger-lib/Hledger/Read/Common.hs b/hledger-lib/Hledger/Read/Common.hs index bf53f5d97..00286c4f5 100644 --- a/hledger-lib/Hledger/Read/Common.hs +++ b/hledger-lib/Hledger/Read/Common.hs @@ -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)