Skip to content

Commit

Permalink
[balsheet-pnl] shorten workload by deduping commodities
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherlam committed Jan 23, 2023
1 parent c16bde1 commit d1b84fa
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions gnucash/report/reports/standard/balsheet-pnl.scm
Expand Up @@ -764,12 +764,17 @@ also show overall period profit & loss."))

;; generate an exchange-fn for date, and cache its result.
(get-date-exchange-fn
(let ((h (make-hash-table)))
(let ((h (make-hash-table))
(commodities (sort-and-delete-duplicates
(map xaccAccountGetCommodity accounts)
(lambda (a b)
(gnc:string-locale<? (gnc-commodity-get-unique-name a)
(gnc-commodity-get-unique-name b)))
gnc-commodity-equal)))
(lambda (date)
(or (hashv-ref h date)
(let ((exchangefn (gnc:case-exchange-time-fn
price-source common-currency
(map xaccAccountGetCommodity accounts)
price-source common-currency commodities
date #f #f)))
(hashv-set! h date exchangefn)
exchangefn)))))
Expand Down

0 comments on commit d1b84fa

Please sign in to comment.