diff options
author | Ivan Molodetskikh <yalterz@gmail.com> | 2022-05-06 17:21:00 +0300 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2022-05-07 10:31:15 -0400 |
commit | a39d55e5b08946cc2eccdb5d57570bc5a38ede10 (patch) | |
tree | a2758dfa64f38dfd244a1037e36b25c1a19fec4b | |
parent | fc5966a34755f40181f6b9f1f137238773b73950 (diff) | |
download | gtk+-a39d55e5b08946cc2eccdb5d57570bc5a38ede10.tar.gz |
listitemfactory: Track notify manually instead of freeze/thaw
freeze/thaw_notify () showed up on the perf trace for rapid ColumnView
scrolling. Track the three properties manually to make it a little
faster.
Related: https://gitlab.gnome.org/GNOME/gtk/-/issues/3334
-rw-r--r-- | gtk/gtklistitemfactory.c | 4 | ||||
-rw-r--r-- | gtk/gtklistitemwidget.c | 21 |
2 files changed, 14 insertions, 11 deletions
diff --git a/gtk/gtklistitemfactory.c b/gtk/gtklistitemfactory.c index 82fa3402db..48383f29de 100644 --- a/gtk/gtklistitemfactory.c +++ b/gtk/gtklistitemfactory.c @@ -162,9 +162,5 @@ gtk_list_item_factory_update (GtkListItemFactory *self, list_item = gtk_list_item_widget_get_list_item (widget); - g_object_freeze_notify (G_OBJECT (list_item)); - GTK_LIST_ITEM_FACTORY_GET_CLASS (self)->update (self, widget, list_item, position, item, selected); - - g_object_thaw_notify (G_OBJECT (list_item)); } diff --git a/gtk/gtklistitemwidget.c b/gtk/gtklistitemwidget.c index 0c9baea963..5ef1d357b7 100644 --- a/gtk/gtklistitemwidget.c +++ b/gtk/gtklistitemwidget.c @@ -554,27 +554,34 @@ gtk_list_item_widget_default_update (GtkListItemWidget *self, gpointer item, gboolean selected) { + /* Track notify manually instead of freeze/thaw_notify for performance reasons. */ + gboolean notify_item = FALSE, notify_position = FALSE, notify_selected = FALSE; GtkListItemWidgetPrivate *priv = gtk_list_item_widget_get_instance_private (self); /* FIXME: It's kinda evil to notify external objects from here... */ if (g_set_object (&priv->item, item)) - { - if (list_item) - g_object_notify (G_OBJECT (list_item), "item"); - } + notify_item = TRUE; if (priv->position != position) { priv->position = position; - if (list_item) - g_object_notify (G_OBJECT (list_item), "position"); + notify_position = TRUE; } if (priv->selected != selected) { priv->selected = selected; - if (list_item) + notify_selected = TRUE; + } + + if (list_item) + { + if (notify_item) + g_object_notify (G_OBJECT (list_item), "item"); + if (notify_position) + g_object_notify (G_OBJECT (list_item), "position"); + if (notify_selected) g_object_notify (G_OBJECT (list_item), "selected"); } } |