gnucash maint: Multiple changes pushed

Christopher Lam clam at code.gnucash.org
Thu Jul 9 10:20:04 EDT 2020


Updated	 via  https://github.com/Gnucash/gnucash/commit/ebb462d0 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/a59d91a9 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/ea56cedd (commit)
	from  https://github.com/Gnucash/gnucash/commit/09e523c0 (commit)



commit ebb462d06d75c62375c48eca9743fdcdd96c8392
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Thu Jul 9 21:19:27 2020 +0800

    [account.cpp] prevent crash in gnc_account_get_currency_or_parent
    
    if the *account argument is NULL, it is not reasonable to have a
    g_assert crash. Passing NULL account returns NULL commodity instead.

diff --git a/libgnucash/engine/Account.cpp b/libgnucash/engine/Account.cpp
index 00ba69a57..7654beee3 100644
--- a/libgnucash/engine/Account.cpp
+++ b/libgnucash/engine/Account.cpp
@@ -3271,7 +3271,7 @@ xaccAccountGetCommodity (const Account *acc)
 gnc_commodity * gnc_account_get_currency_or_parent(const Account* account)
 {
     gnc_commodity * commodity;
-    g_assert(account);
+    g_return_val_if_fail (account, NULL);
 
     commodity = xaccAccountGetCommodity (account);
     if (gnc_commodity_is_currency(commodity))

commit a59d91a94b174bd5f860e8cd0fa677d578b26a90
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Wed Jul 8 23:17:25 2020 +0800

    CMakeLists: mark deprecation of .scm files

diff --git a/gnucash/report/reports/CMakeLists.txt b/gnucash/report/reports/CMakeLists.txt
index dd69a8e3d..deb34de22 100644
--- a/gnucash/report/reports/CMakeLists.txt
+++ b/gnucash/report/reports/CMakeLists.txt
@@ -4,7 +4,7 @@ add_subdirectory(support)
 
 #These provide some functions used by more than one report.
 set (reports_common_SCHEME
-  aging.scm
+  aging.scm                     #deprecated 4.x to be removed in 5.x
   cash-flow-calc.scm
 )
 
@@ -13,10 +13,10 @@ set (reports_common_SCHEME
 set (reports_standard_with_exposed_generator_SCHEME
     standard/new-aging.scm
     standard/register.scm
-    standard/owner-report.scm
+    standard/owner-report.scm   #deprecated 4.x to be removed in 5.x
     standard/new-owner-report.scm
-    standard/payables.scm
-    standard/receivables.scm
+    standard/payables.scm       #deprecated 4.x to be removed in 5.x
+    standard/receivables.scm    #deprecated 4.x to be removed in 5.x
 )
 
 set (reports_standard_SCHEME

commit ea56ceddfacf77fa63863bf9e2456ba02c0f3c9c
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sat Jul 4 23:15:24 2020 +0800

    [lot-viewer] lot accumulator uses hashtable avoiding O(N^2)
    
    IIUC hash-table makes it O(NlogN)

diff --git a/gnucash/report/reports/standard/lot-viewer.scm b/gnucash/report/reports/standard/lot-viewer.scm
index 9e0ae7719..37ee7b2d1 100644
--- a/gnucash/report/reports/standard/lot-viewer.scm
+++ b/gnucash/report/reports/standard/lot-viewer.scm
@@ -74,6 +74,7 @@
      (gnc:lookup-option (gnc:report-options report-obj) section name)))
 
   (define (get-all-lots splits)
+    (define lots-seen (make-hash-table))
     (let lp ((splits splits) (lots '()))
       (match splits
         (() (reverse lots))
@@ -82,8 +83,9 @@
            (lp rest
                (cond
                 ((null? lot) lots)
-                ((member lot lots) lots) ;warning: O(N^2)!
-                (else (cons lot lots)))))))))
+                ((hash-ref lots-seen lot) lots)
+                (else (hash-set! lots-seen lot #t)
+                      (cons lot lots)))))))))
 
   (let* ((to-date (gnc:time64-end-day-time
                    (gnc:date-option-absolute-time



Summary of changes:
 gnucash/report/reports/CMakeLists.txt          | 8 ++++----
 gnucash/report/reports/standard/lot-viewer.scm | 6 ++++--
 libgnucash/engine/Account.cpp                  | 2 +-
 3 files changed, 9 insertions(+), 7 deletions(-)



More information about the gnucash-changes mailing list