From 3af81a73ca4607a8e636436884d7921932a82de8 Mon Sep 17 00:00:00 2001 From: Mykola Orliuk Date: Mon, 16 Jan 2017 17:42:41 +0200 Subject: [PATCH] txnTieKnot fix (~10% memory reduce) (#483) * bin: ignore chart and dupes addons * lib: fix txnTieKnot Ensure that postings refers to their transaction rather than original one. This should allow compiler perform destructive update and/or allow garbage collecting old transaction. --- bin/.gitignore | 2 ++ hledger-lib/Hledger/Data/Transaction.hs | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/bin/.gitignore b/bin/.gitignore index 6a4cb5288..ef37f380d 100644 --- a/bin/.gitignore +++ b/bin/.gitignore @@ -1,4 +1,6 @@ +hledger-chart hledger-check-dates +hledger-dupes hledger-equity hledger-print-unique hledger-register-match diff --git a/hledger-lib/Hledger/Data/Transaction.hs b/hledger-lib/Hledger/Data/Transaction.hs index 64d12dacc..ab84d390f 100644 --- a/hledger-lib/Hledger/Data/Transaction.hs +++ b/hledger-lib/Hledger/Data/Transaction.hs @@ -489,7 +489,8 @@ transactionDate2 t = fromMaybe (tdate t) $ tdate2 t -- | Ensure a transaction's postings refer back to it, so that eg -- relatedPostings works right. txnTieKnot :: Transaction -> Transaction -txnTieKnot t@Transaction{tpostings=ps} = t{tpostings=map (postingSetTransaction t) ps} +txnTieKnot t@Transaction{tpostings=ps} = t' where + t' = t{tpostings=map (postingSetTransaction t') ps} -- | Ensure a transaction's postings do not refer back to it, so that eg -- recursiveSize and GHCI's :sprint work right.