various reports: use more efficient report-utilities.scm functions

instead of delete-duplicates
This commit is contained in:
Christopher Lam 2019-07-20 19:06:16 +08:00
parent ae4b7e1582
commit aa95d61c6c
5 changed files with 7 additions and 28 deletions

View File

@ -292,9 +292,7 @@
(expense-accounts (opt-val pagename-expenseaccounts optname-expenseaccounts))
(sales-accounts (opt-val pagename-incomeaccounts optname-incomeaccounts))
(all-accounts (append sales-accounts expense-accounts))
(commodities (delete-duplicates
(map xaccAccountGetCommodity all-accounts)
gnc-commodity-equiv))
(commodities (gnc:accounts-get-commodities all-accounts #f))
(commodities>1? (> (length commodities) 1))
(book (gnc-get-current-book))
(date-format (gnc:options-fancy-date book))

View File

@ -167,8 +167,7 @@ date point, a projected minimum balance including scheduled transactions."))
(accum (gnc:make-commodity-collector))
(exchange-fn (gnc:case-exchange-time-fn
price currency
(delete-duplicates! (map xaccAccountGetCommodity accounts)
gnc-commodity-equiv)
(gnc:accounts-get-commodities accounts #f)
to-date #f #f))
(accounts-balancelist
(map

View File

@ -802,12 +802,7 @@ also show overall period profit & loss."))
;; missing price, say so.
(get-exchange-rates-fn
(lambda (accounts col-idx)
(let ((commodities (delete
common-currency
(delete-duplicates
(map xaccAccountGetCommodity accounts)
gnc-commodity-equal)
gnc-commodity-equal))
(let ((commodities (gnc:accounts-get-commodities accounts common-currency))
(cell (gnc:make-html-text)))
(for-each
(lambda (commodity)

View File

@ -375,8 +375,7 @@ developing over time"))
(xaccSplitGetAmount s))))))))
;; all selected accounts (of report-specific type), *and*
;; their descendants (of any type) need to be scanned.
(delete-duplicates
(append accounts (gnc:acccounts-get-all-subaccounts accounts)))))
(gnc:accounts-and-all-descendants accounts)))
;; Creates the <balance-list> to be used in the function
;; below.

View File

@ -227,20 +227,8 @@
;; if requested)
(gnc:report-percent-done 25)
(if dosubs?
(let ((subaccts '()))
(for-each
(lambda (acct)
(let ((this-acct-subs
(gnc-account-get-descendants-sorted acct)))
(if (list? this-acct-subs)
(set! subaccts
(append subaccts this-acct-subs)))))
accounts)
;; Beware: delete-duplicates is an O(n^2)
;; algorithm. More efficient method: sort the list,
;; then use a linear algorithm.
(set! accounts
(delete-duplicates (append accounts subaccts)))))
(gnc:accounts-and-all-descendants accounts)))
(gnc:report-percent-done 30)
(xaccQueryAddAccountMatch query accounts QOF-GUID-MATCH-ANY QOF-QUERY-AND)