gnucash maint: Multiple changes pushed
Christopher Lam
clam at code.gnucash.org
Wed Oct 20 07:35:19 EDT 2021
Updated via https://github.com/Gnucash/gnucash/commit/f0970c8e (commit)
via https://github.com/Gnucash/gnucash/commit/31a0300a (commit)
via https://github.com/Gnucash/gnucash/commit/6bcd6902 (commit)
from https://github.com/Gnucash/gnucash/commit/a3fedfe5 (commit)
commit f0970c8eb4c1a711aa58738096353ba22e629308
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Tue Oct 19 22:54:00 2021 +0800
[gnc-features] don't repeatedly g_strconcat gchars*
diff --git a/libgnucash/engine/gnc-features.c b/libgnucash/engine/gnc-features.c
index 10ea1009c..f710677d2 100644
--- a/libgnucash/engine/gnc-features.c
+++ b/libgnucash/engine/gnc-features.c
@@ -31,6 +31,7 @@
#include "qof.h"
#include "gnc-features.h"
+#include "gnc-glib-utils.h"
typedef struct
{
@@ -115,20 +116,15 @@ gchar *gnc_features_test_unknown (QofBook *book)
&features_list);
if (features_list)
{
- GList *i;
- char* msg = g_strdup(_("This Dataset contains features not supported "
- "by this version of GnuCash. You must use a "
- "newer version of GnuCash in order to support "
- "the following features:"
- ));
-
- for (i = features_list; i; i = i->next)
- {
- char *tmp = g_strconcat(msg, "\n* ", i->data, NULL);
- g_free (msg);
- msg = tmp;
- }
-
+ const char* sep = "\n* ";
+ const char* header = _("This Dataset contains features not supported "
+ "by this version of GnuCash. You must use a "
+ "newer version of GnuCash in order to support "
+ "the following features:");
+
+ char *features_str = gnc_g_list_stringjoin (features_list, sep);
+ char *msg = g_strconcat (header, sep, features_str, NULL);
+ g_free (features_str);
g_list_free(features_list);
return msg;
}
commit 31a0300abe9baa6c145a668fe058ec45264477e6
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Tue Oct 19 19:15:35 2021 +0800
[Recurrence.c] avoid repeated calls to g_list_length
diff --git a/libgnucash/engine/Recurrence.c b/libgnucash/engine/Recurrence.c
index 1db0cd7d7..1f8647fc3 100644
--- a/libgnucash/engine/Recurrence.c
+++ b/libgnucash/engine/Recurrence.c
@@ -685,14 +685,15 @@ gchar*
recurrenceListToCompactString(GList *rs)
{
GString *buf = g_string_sized_new(16);
+ gint rs_len = g_list_length (rs);
- if (g_list_length(rs) == 0)
+ if (rs_len == 0)
{
g_string_printf(buf, "%s", _("None"));
goto rtn;
}
- if (g_list_length(rs) > 1)
+ if (rs_len > 1)
{
if (recurrenceListIsWeeklyMultiple(rs))
{
@@ -724,7 +725,7 @@ recurrenceListToCompactString(GList *rs)
else
{
/* Translators: %d is the number of Recurrences in the list. */
- g_string_printf(buf, _("Unknown, %d-size list."), g_list_length(rs));
+ g_string_printf(buf, _("Unknown, %d-size list."), rs_len);
}
}
else
commit 6bcd69026b6c09ead4ac1daad461a960f8dd362b
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Tue Oct 19 19:12:33 2021 +0800
[gnc-budget-view] avoid O(N^2) g_list_length calls
diff --git a/gnucash/gnome/gnc-budget-view.c b/gnucash/gnome/gnc-budget-view.c
index 0516ff054..c9a1e4672 100644
--- a/gnucash/gnome/gnc-budget-view.c
+++ b/gnucash/gnome/gnc-budget-view.c
@@ -1590,7 +1590,7 @@ gnc_budget_view_refresh (GncBudgetView *budget_view)
col = GTK_TREE_VIEW_COLUMN((g_list_last (col_list))->data);
gtk_tree_view_remove_column (GTK_TREE_VIEW(priv->tree_view), col);
col_list = g_list_delete_link (col_list, g_list_last (col_list));
- num_periods_visible = g_list_length (col_list);
+ num_periods_visible--;
col = GTK_TREE_VIEW_COLUMN(totals_col_list->data);
gtk_tree_view_remove_column (GTK_TREE_VIEW(priv->totals_tree_view), col);
@@ -1653,7 +1653,7 @@ gnc_budget_view_refresh (GncBudgetView *budget_view)
totals_col_list = g_list_prepend (totals_col_list, col);
}
- num_periods_visible = g_list_length (col_list);
+ num_periods_visible++;
}
gdk_rgba_free (note_color);
Summary of changes:
gnucash/gnome/gnc-budget-view.c | 4 ++--
libgnucash/engine/Recurrence.c | 7 ++++---
libgnucash/engine/gnc-features.c | 24 ++++++++++--------------
3 files changed, 16 insertions(+), 19 deletions(-)
More information about the gnucash-changes
mailing list