Speed-up of dealing with account_imap lists: Replace g_list_append with _prepend and subsequent _reverse.

This is glib's suggested way of dealing with GList in more optimized
way, as g_list_append will have to traverse the list until the end.
This commit is contained in:
Christian Stimming
2019-01-01 13:39:56 +01:00
parent c9bd68c658
commit 75b6d14455

View File

@@ -5555,7 +5555,7 @@ build_non_bayes (const char *key, const GValue *value, gpointer user_data)
imapInfo_node->category = g_strdup (imapInfo->category); imapInfo_node->category = g_strdup (imapInfo->category);
imapInfo_node->count = g_strdup (" "); imapInfo_node->count = g_strdup (" ");
imapInfo->list = g_list_append (imapInfo->list, imapInfo_node); imapInfo->list = g_list_prepend (imapInfo->list, imapInfo_node);
g_free (guid_string); g_free (guid_string);
} }
@@ -5594,7 +5594,7 @@ build_bayes (const char *key, KvpValue * value, GncImapInfo & imapInfo)
imap_node->match_string = g_strdup (std::get <1> (parsed_key).c_str ()); imap_node->match_string = g_strdup (std::get <1> (parsed_key).c_str ());
imap_node->category = g_strdup(" "); imap_node->category = g_strdup(" ");
imap_node->count = g_strdup_printf ("%" G_GINT64_FORMAT, count); imap_node->count = g_strdup_printf ("%" G_GINT64_FORMAT, count);
imapInfo.list = g_list_append (imapInfo.list, imap_node); imapInfo.list = g_list_prepend (imapInfo.list, imap_node);
} }
GList * GList *
@@ -5605,7 +5605,7 @@ gnc_account_imap_get_info_bayes (Account *acc)
* of data about which we care. */ * of data about which we care. */
GncImapInfo imapInfo {acc, nullptr}; GncImapInfo imapInfo {acc, nullptr};
qof_instance_foreach_slot_prefix (QOF_INSTANCE (acc), IMAP_FRAME_BAYES, &build_bayes, imapInfo); qof_instance_foreach_slot_prefix (QOF_INSTANCE (acc), IMAP_FRAME_BAYES, &build_bayes, imapInfo);
return imapInfo.list; return g_list_reverse(imapInfo.list);
} }
GList * GList *
@@ -5630,7 +5630,7 @@ gnc_account_imap_get_info (Account *acc, const char *category)
qof_instance_foreach_slot (QOF_INSTANCE(acc), IMAP_FRAME, category, qof_instance_foreach_slot (QOF_INSTANCE(acc), IMAP_FRAME, category,
build_non_bayes, &imapInfo); build_non_bayes, &imapInfo);
} }
return imapInfo.list; return g_list_reverse(imapInfo.list);
} }
/*******************************************************************************/ /*******************************************************************************/