gnucash maint: Multiple changes pushed

Christopher Lam clam at code.gnucash.org
Mon Jun 27 12:01:59 EDT 2022


Updated	 via  https://github.com/Gnucash/gnucash/commit/0ab31763 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/bf0d532b (commit)
	from  https://github.com/Gnucash/gnucash/commit/394f2b43 (commit)



commit 0ab31763e4cf1d96c56f07f51aa41ce4abba6183
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Mon Jun 27 23:23:39 2022 +0800

    [cellblock.c] free the cells
    
    was leaking at least 256 bytes per cell block

diff --git a/gnucash/register/register-core/cellblock.c b/gnucash/register/register-core/cellblock.c
index 51e0a0ddd..feabf0f1f 100644
--- a/gnucash/register/register-core/cellblock.c
+++ b/gnucash/register/register-core/cellblock.c
@@ -79,7 +79,7 @@ gnc_cellblock_destroy (CellBlock *cellblock)
 {
     if (!cellblock) return;
 
-    g_ptr_array_free (cellblock->cells, FALSE);
+    g_ptr_array_free (cellblock->cells, TRUE);
     cellblock->cells = NULL;
 
     g_free (cellblock->cursor_name);

commit bf0d532b3d1cf17d5c6d516319cd71d15f223bc6
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Mon Jun 27 21:06:49 2022 +0800

    [trep-engine] refactor grid data structure functions
    
    trep will never insert more than 1 datum in a cell.

diff --git a/gnucash/report/trep-engine.scm b/gnucash/report/trep-engine.scm
index ec21d6d78..20d854de2 100644
--- a/gnucash/report/trep-engine.scm
+++ b/gnucash/report/trep-engine.scm
@@ -1881,25 +1881,22 @@ be excluded from periodic reporting.")
    (lambda (cell)
      (cell-match? cell row col))
    grid))
-(define (grid-del grid row col)
-  ;; grid filter - del all row/col - if #f then delete whole row/col
-  (filter
-   (lambda (cell)
-     (not (cell-match? cell row col)))
-   grid))
 (define (grid-rows grid)
   (delete-duplicates (map (lambda (cell) (vector-ref cell 0)) grid)))
 (define (grid-cols grid)
   (delete-duplicates (map (lambda (cell) (vector-ref cell 1)) grid)))
 (define (grid-add grid row col data)
-  ;;misonomer - we don't 'add' to existing data, we delete old data
-  ;;stored at row/col and add again. this is fine because the grid
-  ;;should never have duplicate data in the trep.
-  (set! grid (grid-del grid row col))
-  (set! grid (cons (vector row col data) grid))
-  grid)
-(define (grid->html-table grid list-of-rows list-of-cols)
-  (define row-average-enabled? (> (length list-of-cols) 1))
+  ;; we don't need to check for duplicate cells in a row/col because
+  ;; in the trep it should never happen.
+  (cons (vector row col data) grid))
+(define (grid->html-table grid)
+  (define (<? a b)
+    (cond ((string? (car a)) (gnc:string-locale<? (car a) (car b)))
+          ((number? (car a)) (< (car a) (car b)))
+          (else (gnc:error "unknown sortvalue"))))
+  (define list-of-rows (sort (delete 'row-total (grid-rows grid)) <?))
+  (define list-of-cols (sort (delete 'col-total (grid-cols grid)) <?))
+  (define row-average-enabled? (pair? (cdr list-of-cols)))
   (define (monetary-div monetary divisor)
     (and monetary
          (let* ((amount (gnc:gnc-monetary-amount monetary))
@@ -2276,19 +2273,7 @@ warning will be removed in GnuCash 5.0"))
              (gnc:html-render-options-changed options)))
 
           (when subtotal-table?
-            (let* ((generic<?
-                    (lambda (a b)
-                      (cond ((string? (car a)) (gnc:string-locale<? (car a) (car b)))
-                            ((number? (car a)) (< (car a) (car b)))
-                            (else (gnc:error "unknown sortvalue")))))
-                   (list-of-rows
-                    (stable-sort! (delete 'row-total (grid-rows grid))
-                                  generic<?))
-                   (list-of-cols
-                    (stable-sort! (delete 'col-total (grid-cols grid))
-                                  generic<?)))
-              (gnc:html-document-add-object!
-               document (grid->html-table grid list-of-rows list-of-cols))))
+            (gnc:html-document-add-object! document (grid->html-table grid)))
 
           (unless (and subtotal-table?
                        (opt-val pagename-sorting optname-show-subtotals-only))



Summary of changes:
 gnucash/register/register-core/cellblock.c |  2 +-
 gnucash/report/trep-engine.scm             | 39 +++++++++---------------------
 2 files changed, 13 insertions(+), 28 deletions(-)



More information about the gnucash-changes mailing list