listitemfactory: Track notify manually instead of freeze/thaw
authorIvan Molodetskikh <yalterz@gmail.com>
Fri, 6 May 2022 14:21:00 +0000 (17:21 +0300)
committerIvan Molodetskikh <yalterz@gmail.com>
Fri, 6 May 2022 14:31:24 +0000 (17:31 +0300)
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

gtk/gtklistitemfactory.c
gtk/gtklistitemwidget.c

index 82fa3402dbd7fd3a834fe4930a2b540f043fd5db..48383f29de16fdcf7e889819e88c2f40d9d4bdb6 100644 (file)
@@ -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));
 }
index 0c9baea963c56808a09bccbd164d04e9973340f5..5ef1d357b75ba1a664c650961d80772c17f29982 100644 (file)
@@ -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");
     }
 }