From 2ac8cb2f79bdff1e2f811b37e635d388c6f297f1 Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Tue, 3 Sep 2019 07:06:05 +0800 Subject: [PATCH] [reports] use more efficient gnc:accounts-and-all-descendants All uses of gnc:acccounts-get-all-subaccounts were immediately followed by appending the result to the original accounts list. Use gnc:accounts-and-all-descendants instead which is more efficient. --- gnucash/report/standard-reports/average-balance.scm | 8 +++----- gnucash/report/standard-reports/budget.scm | 8 +++----- gnucash/report/standard-reports/cash-flow.scm | 8 +++----- gnucash/report/standard-reports/category-barchart.scm | 4 +--- gnucash/report/standard-reports/daily-reports.scm | 6 ++---- gnucash/report/standard-reports/net-charts.scm | 4 +--- gnucash/report/standard-reports/portfolio.scm | 5 ++--- 7 files changed, 15 insertions(+), 28 deletions(-) diff --git a/gnucash/report/standard-reports/average-balance.scm b/gnucash/report/standard-reports/average-balance.scm index e0308299e0..07d2390656 100644 --- a/gnucash/report/standard-reports/average-balance.scm +++ b/gnucash/report/standard-reports/average-balance.scm @@ -293,11 +293,9 @@ (internal-included (not (get-option gnc:pagename-accounts optname-internal))) (accounts (get-option gnc:pagename-accounts (N_ "Accounts"))) (dosubs? (get-option gnc:pagename-accounts optname-subacct)) - (accounts (append accounts - (if dosubs? - (filter (lambda (acc) (not (member acc accounts))) - (gnc:acccounts-get-all-subaccounts accounts)) - '()))) + (accounts (if dosubs? + (gnc:accounts-and-all-descendants accounts) + accounts)) (plot-type (get-option gnc:pagename-display (N_ "Plot Type"))) (show-plot? (get-option gnc:pagename-display (N_ "Show plot"))) (show-table? (get-option gnc:pagename-display (N_ "Show table"))) diff --git a/gnucash/report/standard-reports/budget.scm b/gnucash/report/standard-reports/budget.scm index e09c3124ff..16fcbe1a8a 100644 --- a/gnucash/report/standard-reports/budget.scm +++ b/gnucash/report/standard-reports/budget.scm @@ -638,11 +638,9 @@ (get-option gnc:pagename-general optname-period-collapse-after))) (doc (gnc:make-html-document)) - (accounts (append accounts - (filter (lambda (acc) (not (member acc accounts))) - (if show-subaccts? - (gnc:acccounts-get-all-subaccounts accounts) - '()))))) + (accounts (if show-subaccts? + (gnc:accounts-and-all-descendants accounts) + accounts))) ;; end of defines (cond diff --git a/gnucash/report/standard-reports/cash-flow.scm b/gnucash/report/standard-reports/cash-flow.scm index fd61a006dd..9a35699d2a 100644 --- a/gnucash/report/standard-reports/cash-flow.scm +++ b/gnucash/report/standard-reports/cash-flow.scm @@ -156,11 +156,9 @@ (table (gnc:make-html-table)) ;;add subaccounts if requested - (accounts (append accounts - (filter (lambda (acc) (not (member acc accounts))) - (if show-subaccts? - (gnc:acccounts-get-all-subaccounts accounts) - '())))) + (accounts (if show-subaccts? + (gnc:accounts-and-all-descendants accounts) + accounts)) (accounts (sort accounts account-full-name