minor optimisations, g_list_prepend then g_list_sort separately

if building a g_list incrementally, don't sort on each insertion.
This commit is contained in:
Christopher Lam 2020-09-30 09:50:54 +08:00
parent 5c06f7f8c0
commit 6eb2e36c2d
2 changed files with 7 additions and 5 deletions

View File

@ -3933,12 +3933,12 @@ xaccAccountFindOpenLots (const Account *acc,
continue;
/* Ok, this is a valid lot. Add it to our list of lots */
if (sort_func)
retval = g_list_insert_sorted (retval, lot, sort_func);
else
retval = g_list_prepend (retval, lot);
retval = g_list_prepend (retval, lot);
}
if (sort_func)
retval = g_list_sort (retval, sort_func);
return retval;
}

View File

@ -1045,13 +1045,15 @@ gncOwnerSetLotLinkMemo (Transaction *ll_txn)
title = g_strdup_printf ("%s %s", gncInvoiceGetTypeString (invoice), gncInvoiceGetID (invoice));
titles = g_list_insert_sorted (titles, title, (GCompareFunc)g_strcmp0);
titles = g_list_prepend (titles, title);
splits = g_list_prepend (splits, split); // splits don't need to be sorted
}
if (!titles)
return; // We didn't find document lots
titles = g_list_sort (titles, (GCompareFunc)g_strcmp0);
// Create the memo as we'd want it to be
new_memo = g_strconcat (memo_prefix, titles->data, NULL);
for (titer = titles->next; titer; titer = titer->next)