Skip to content

Commit

Permalink
[balsheet-pnl] faster definition of balance lists
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
christopherlam committed Apr 11, 2022
1 parent 736d223 commit 1420368
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions gnucash/report/reports/standard/balsheet-pnl.scm
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit 1420368

Please sign in to comment.