[balsheet-pnl] faster definition of balance lists

because the accounts and accounts-cols-data have direct 1-to-1
mapping, it is not necessary to map accounts and retrieve from
accounts-cols-data. mapping from accounts-cols-data produces
identical results, avoiding O(N^2) access from accounts-cols-data.
This commit is contained in:
Christopher Lam 2022-04-11 09:36:52 +08:00
parent 736d223198
commit 1420368b5b

View File

@ -753,17 +753,17 @@ also show overall period profit & loss."))
;; account-balances is a list of monetary amounts
(accounts-balances
(map
(lambda (acc)
(cons acc (let ((cols-data (assoc-ref accounts-cols-data acc)))
(map col-datum-get-split-balance cols-data))))
accounts))
(match-lambda
((acc . cols-data)
(cons acc (map col-datum-get-split-balance cols-data))))
accounts-cols-data))
(accounts-balances-with-closing
(map
(lambda (acc)
(cons acc (let ((cols-data (assoc-ref accounts-cols-data acc)))
(map col-datum-get-split-balance-with-closing cols-data))))
accounts))
(match-lambda
((acc . cols-data)
(cons acc (map col-datum-get-split-balance-with-closing cols-data))))
accounts-cols-data))
(exchange-fn (and common-currency
(gnc:case-exchange-time-fn
@ -914,11 +914,10 @@ also show overall period profit & loss."))
;; split is the last one at date boundary
(accounts-splits-dates
(map
(lambda (acc)
(cons acc (let ((cols-data (assoc-ref accounts-cols-data acc)))
(list->vector
(map col-datum-get-last-split cols-data)))))
accounts))
(match-lambda
((acc . cols-data)
(cons acc (list->vector (map col-datum-get-last-split cols-data)))))
accounts-cols-data))
(get-cell-anchor-fn
(lambda (account col-idx)
@ -944,10 +943,10 @@ also show overall period profit & loss."))
;; dates. split-value-balance determined by transaction currency.
(accounts-value-balances
(map
(lambda (acc)
(cons acc (let ((cols-data (assoc-ref accounts-cols-data acc)))
(map col-datum-get-split-value-balance cols-data))))
accounts))
(match-lambda
((acc . cols-data)
(cons acc (map col-datum-get-split-value-balance cols-data))))
accounts-cols-data))
;; a vector of collectors whereby each collector is the sum
;; of asset and liability split-value-balances at report