gnucash stable: Multiple changes pushed
Christopher Lam
clam at code.gnucash.org
Mon Jun 29 21:58:30 EDT 2026
Updated via https://github.com/Gnucash/gnucash/commit/d548b801 (commit)
via https://github.com/Gnucash/gnucash/commit/732ad466 (commit)
from https://github.com/Gnucash/gnucash/commit/c3a74e6a (commit)
commit d548b801de2162832ff0637a7bbad693c41e374a
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Tue Jun 30 06:50:59 2026 +0800
[html-acct-table.scm] avoid gnc:account-get-trans-type-splits-interval
replace with faster split accumulator
diff --git a/gnucash/report/html-acct-table.scm b/gnucash/report/html-acct-table.scm
index 2a31252bf4..7c9ce57dcb 100644
--- a/gnucash/report/html-acct-table.scm
+++ b/gnucash/report/html-acct-table.scm
@@ -625,31 +625,28 @@
accts))
(define (calculate-balances-simple)
- (define (merge-splits splits subtract?)
- (for-each
- (lambda (split)
- (let* ((acct (xaccSplitGetAccount split))
- (guid (gncAccountGetGUID acct))
- (acct-comm (xaccAccountGetCommodity acct))
- (shares (xaccSplitGetAmount split))
- (hash (hash-ref ret-hash guid)))
- (unless hash
- (set! hash (gnc:make-commodity-collector))
- (hash-set! ret-hash guid hash))
- (hash 'add acct-comm (if subtract? (- shares) shares))))
- splits))
-
- (merge-splits (gnc:account-get-trans-type-splits-interval
- accts #f start-date end-date)
- #f)
+
+ (define (merge-split split minus?)
+ (let* ((acct (xaccSplitGetAccount split))
+ (amt (xaccSplitGetAmount split))
+ (coll (gnc:hash-ref! ret-hash (gncAccountGetGUID acct)
+ gnc:make-commodity-collector)))
+ (coll 'add (xaccAccountGetCommodity acct) (if minus? (- amt) amt))))
+
+ (for-each
+ (lambda (acc)
+ (gnc-account-foreach-split-between-dates
+ acc start-date end-date #f (lambda (s) (merge-split s #f))))
+ accts)
(case balance-mode
((post-closing) #f)
;; remove closing entries
((pre-closing)
- (merge-splits (gnc:account-get-trans-type-splits-interval
- accts closing-pattern start-date end-date) #t))
+ (for-each (lambda (s) (merge-split s #t))
+ (gnc:account-get-trans-type-splits-interval
+ accts closing-pattern start-date end-date)))
(else
(display "you fail it\n"))))
commit 732ad466eea20fe09f5a130e8e715e5817cafea9
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Tue Jun 30 09:48:44 2026 +0800
[report-utilities.scm] upgrade hash-ref! to report-utilities.scm
diff --git a/gnucash/report/report-utilities.scm b/gnucash/report/report-utilities.scm
index eb61a555f5..d881fa0e4d 100644
--- a/gnucash/report/report-utilities.scm
+++ b/gnucash/report/report-utilities.scm
@@ -34,6 +34,7 @@
(use-modules (gnucash report html-acct-table))
(use-modules (gnucash gnome-utils))
+(export gnc:hash-ref!)
(export list-ref-safe)
(export list-set-safe!)
(export gnc:monetary->string)
@@ -107,6 +108,15 @@
(export gnc:dump-invoices)
(export gnc:dump-lot)
+
+;; mimics c++ std::unordered_map::operator[] - return the value corresponding to key,
+;; constructing a new value in the map if key does not exist yet
+(define (gnc:hash-ref! hash key constructor)
+ (or (hash-ref hash key)
+ (let ((new-value (constructor)))
+ (hash-set! hash key new-value)
+ new-value)))
+
(define (list-ref-safe list elt)
(and (pair? list)
(if (<= elt 0)
diff --git a/gnucash/report/trep-engine.scm b/gnucash/report/trep-engine.scm
index cee742975a..e6c139fc4a 100644
--- a/gnucash/report/trep-engine.scm
+++ b/gnucash/report/trep-engine.scm
@@ -515,14 +515,6 @@ in the Options panel."))
(define (hash-keys hash)
(hash-fold (lambda (k _ p) (cons k p)) '() hash))
-;; mimics c++ std::map::operator[] - return the value corresponding to key,
-;; creating a new value if there's no existing one
-(define (hash-ref! hash key constructor)
- (or (hash-ref hash key)
- (let ((new-value (constructor)))
- (hash-set! hash key new-value)
- new-value)))
-
;;
;; Default Transaction Report
;;
@@ -2103,9 +2095,9 @@ be excluded from periodic reporting.")
;; - Records commodities in this row
(define (grid-add row col data)
(hash-set! cols col #t)
- (let* ((cells-row-ht (hash-ref! cells row make-hash-table))
- (cells-row-col-data (hash-ref! cells-row-ht col gnc:make-commodity-collector))
- (rows-ht (hash-ref! rows row make-hash-table)))
+ (let* ((cells-row-ht (gnc:hash-ref! cells row make-hash-table))
+ (cells-row-col-data (gnc:hash-ref! cells-row-ht col gnc:make-commodity-collector))
+ (rows-ht (gnc:hash-ref! rows row make-hash-table)))
(for-each
(lambda (mon)
(let ((comm (gnc:gnc-monetary-commodity mon)) (amt (gnc:gnc-monetary-amount mon)))
Summary of changes:
gnucash/report/html-acct-table.scm | 35 ++++++++++++++++-------------------
gnucash/report/report-utilities.scm | 10 ++++++++++
gnucash/report/trep-engine.scm | 14 +++-----------
3 files changed, 29 insertions(+), 30 deletions(-)
More information about the gnucash-changes
mailing list