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.
This commit is contained in:
Mykola Orliuk 2017-01-16 17:42:41 +02:00 committed by Simon Michael
parent d657374ac4
commit 3af81a73ca
2 changed files with 4 additions and 1 deletions

2
bin/.gitignore vendored
View File

@ -1,4 +1,6 @@
hledger-chart
hledger-check-dates
hledger-dupes
hledger-equity
hledger-print-unique
hledger-register-match

View File

@ -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.