gnucash maint: Multiple changes pushed

Christopher Lam clam at code.gnucash.org
Tue Oct 13 09:42:23 EDT 2020


Updated	 via  https://github.com/Gnucash/gnucash/commit/cca3be7c (commit)
	 via  https://github.com/Gnucash/gnucash/commit/44486a72 (commit)
	from  https://github.com/Gnucash/gnucash/commit/f599925b (commit)



commit cca3be7c81582b1ad92156d81f8c00ec76daf19f
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sun Oct 11 09:29:34 2020 +0800

    [window-autoclear.c] don't use g_str_hash on a double
    
    use g_double_hash which is present since glib-2.22 now that minimum
    glib is 2.56

diff --git a/gnucash/gnome/window-autoclear.c b/gnucash/gnome/window-autoclear.c
index 637cd146a..3f7055c98 100644
--- a/gnucash/gnome/window-autoclear.c
+++ b/gnucash/gnome/window-autoclear.c
@@ -107,7 +107,7 @@ ght_gnc_numeric_hash(gconstpointer v1)
 {
     gnc_numeric n1 = *(gnc_numeric *)v1;
     gdouble d1 = gnc_numeric_to_double(n1);
-    return g_str_hash(&d1);
+    return g_double_hash (&d1);
 }
 
 typedef struct _sack_foreach_data_t

commit 44486a72a39c8cceda9e9232ae5bbad01075e346
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sun Oct 11 07:35:01 2020 +0800

    [window-autoclear.c] prepend instead of append
    
    This knapsack algorithm is heavy on list manipulation. Speedup by
    avoiding O(N^2) g_list_append. The list ordering is not useful in
    knapsack, therefore there's no need to g_list_reverse.

diff --git a/gnucash/gnome/window-autoclear.c b/gnucash/gnome/window-autoclear.c
index b13ff693b..637cd146a 100644
--- a/gnucash/gnome/window-autoclear.c
+++ b/gnucash/gnome/window-autoclear.c
@@ -122,7 +122,8 @@ static void sack_foreach_func(gpointer key, gpointer value, gpointer user_data)
     gnc_numeric thisvalue = *(gnc_numeric *)key;
 
     gnc_numeric reachable_value = gnc_numeric_add_fixed(thisvalue, data->split_value);
-    data->reachable_list = g_list_append(data->reachable_list, g_memdup(&reachable_value, sizeof(gnc_numeric)));
+    data->reachable_list = g_list_prepend
+        (data->reachable_list, g_memdup (&reachable_value, sizeof (gnc_numeric)));
     PINFO("    Sack: found %s, added %s\n", gnc_numeric_to_string(thisvalue), gnc_numeric_to_string(reachable_value));
 }
 
@@ -151,7 +152,7 @@ gnc_autoclear_window_ok_cb (GtkWidget *widget,
         value = xaccSplitGetAmount (split);
 
         if (recn == NREC)
-            nc_list = g_list_append(nc_list, split);
+            nc_list = g_list_prepend (nc_list, split);
         else
             toclear_value = gnc_numeric_sub_fixed(toclear_value, value);
     }
@@ -189,7 +190,8 @@ gnc_autoclear_window_ok_cb (GtkWidget *widget,
         g_hash_table_foreach (sack, sack_foreach_func, data);
 
         /* Add the value of the split itself to the reachable_list */
-        data->reachable_list = g_list_append(data->reachable_list, g_memdup(&split_value, sizeof(gnc_numeric)));
+        data->reachable_list = g_list_prepend
+            (data->reachable_list, g_memdup (&split_value, sizeof (gnc_numeric)));
 
         /* Add everything to the sack, looking out for duplicates */
         for (node = data->reachable_list; node; node = node->next)



Summary of changes:
 gnucash/gnome/window-autoclear.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)



More information about the gnucash-changes mailing list