From 1c64385614ec8a14912b577fe6b2d4a4ba09627a Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Thu, 5 Dec 2019 09:57:23 +0800 Subject: [PATCH] base-typemaps: avoid slow g_list_nth_data scan GList via glist pointer links rather than incrementing index. --- common/base-typemaps.i | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common/base-typemaps.i b/common/base-typemaps.i index 33e9dffb71..98fbe30279 100644 --- a/common/base-typemaps.i +++ b/common/base-typemaps.i @@ -268,12 +268,12 @@ typedef char gchar; %typemap(out) GList *, CommodityList *, SplitList *, AccountList *, LotList *, MonetaryList *, PriceList *, EntryList * { - guint i; gpointer data; + GList *l; PyObject *list = PyList_New(0); - for (i = 0; i < g_list_length($1); i++) + for (l = $1; l != NULL; l = l->next) { - data = g_list_nth_data($1, i); + data = l->data; if (GNC_IS_ACCOUNT(data)) PyList_Append(list, SWIG_NewPointerObj(data, SWIGTYPE_p_Account, 0)); else if (GNC_IS_SPLIT(data))