Index: articlelist.c =================================================================== RCS file: /cvs/gnome/pan/pan/articlelist.c,v retrieving revision 1.602 diff -u -r1.602 articlelist.c --- articlelist.c 3 Feb 2003 20:58:02 -0000 1.602 +++ articlelist.c 4 Feb 2003 08:54:21 -0000 @@ -1230,10 +1230,30 @@ pan_unlock (); g_static_mutex_unlock (&article_ctree_lock); - /* remove them from our array */ - for (i=0; ilen; ++i) { - const Article * needle = ARTICLE(g_ptr_array_index(articles,i)); - g_ptr_array_remove (my_articles, (gpointer)needle); + /* remove them from our array. + * for small numbers g_ptr_array_remove() is okay, but for huge groups we're + * better off just rebuilding my_articles than to memmove + * 50000 pointers 30000 times. */ + if (articles->len < 5) { + /* low overhead, good if user just hit 'delete' key on an article */ + for (i=0; ilen; ++i) + g_ptr_array_remove (my_articles, g_ptr_array_index (articles, i)); + } else { + /* more overhead, but scales better */ + GHashTable * del_hash = g_hash_table_new (g_str_hash, g_str_equal); + GPtrArray * tmp = g_ptr_array_sized_new (my_articles->len); + for (i=0; ilen; ++i) { + Article * a = ARTICLE (g_ptr_array_index (articles, i)); + g_hash_table_insert (del_hash, (gpointer)article_get_message_id(a), a); + } + for (i=0; ilen; ++i) { + Article * a = ARTICLE (g_ptr_array_index (my_articles, i)); + if (g_hash_table_lookup (del_hash, article_get_message_id (a)) == NULL) + g_ptr_array_add (tmp, a); + } + pan_g_ptr_array_assign (my_articles, tmp->pdata, tmp->len); + g_ptr_array_free (tmp, TRUE); + g_hash_table_destroy (del_hash); } }