From ea0d4901ab67c636e5854b1e4c8fdc34dd1abe05 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Wed, 25 Nov 2020 21:01:05 -0800 Subject: [PATCH] lib: journalApplyAliases performance tweak --- hledger-lib/Hledger/Data/Journal.hs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hledger-lib/Hledger/Data/Journal.hs b/hledger-lib/Hledger/Data/Journal.hs index a82a220c7..a3672ec8f 100644 --- a/hledger-lib/Hledger/Data/Journal.hs +++ b/hledger-lib/Hledger/Data/Journal.hs @@ -1230,6 +1230,8 @@ postingFindTag tagname p = find ((tagname==) . fst) $ postingAllTags p -- | Apply some account aliases to all posting account names in the journal, as described by accountNameApplyAliases. -- This can fail due to a bad replacement pattern in a regular expression alias. journalApplyAliases :: [AccountAlias] -> Journal -> Either RegexError Journal +-- short circuit the common case, just in case there's a performance impact from txnTieKnot etc. +journalApplyAliases [] j = Right j journalApplyAliases aliases j = case mapM (transactionApplyAliases aliases) $ jtxns j of Right ts -> Right j{jtxns = ts}