[gedit/gnome-3-0] Fix slowdown when closing all tabs
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit/gnome-3-0] Fix slowdown when closing all tabs
- Date: Wed, 29 Jun 2011 15:47:22 +0000 (UTC)
commit e483ab955254245bc828010081cf1b3f9f858e29
Author: Paolo Borelli <pborelli gnome org>
Date: Sun Jun 26 22:43:54 2011 +0200
Fix slowdown when closing all tabs
We were O^2 stupid: for each tab we were getting its position, which in
turns requires walking the list of children and then we were removing
the tab, which in turns requires gtk to re-walk the list of tabs to find
the one we want to remove. Besides removing tabs starting from the first
is bad for gtknotebook since even/odd css of each tab is recalculated
over and over: we can remove tabs in reverse order.
gedit/gedit-notebook.c | 16 ++++++++++++----
1 files changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/gedit/gedit-notebook.c b/gedit/gedit-notebook.c
index c61fa63..942a487 100644
--- a/gedit/gedit-notebook.c
+++ b/gedit/gedit-notebook.c
@@ -621,15 +621,23 @@ gedit_notebook_remove_tab (GeditNotebook *nb,
*/
void
gedit_notebook_remove_all_tabs (GeditNotebook *nb)
-{
+{
+ GList *tabs, *t;
+
g_return_if_fail (GEDIT_IS_NOTEBOOK (nb));
g_list_free (nb->priv->focused_pages);
nb->priv->focused_pages = NULL;
- gtk_container_foreach (GTK_CONTAINER (nb),
- (GtkCallback)remove_tab,
- nb);
+ /* Remove tabs in reverse order since it is faster
+ * due to how gtknotebook works */
+ tabs = gtk_container_get_children (GTK_CONTAINER (nb));
+ for (t = g_list_last (tabs); t != NULL; t = t->prev)
+ {
+ gtk_container_remove (GTK_CONTAINER (nb), GTK_WIDGET (t->data));
+ }
+
+ g_list_free (tabs);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]