list-item: Use notify_by_pspec instead of by name
authorIvan Molodetskikh <yalterz@gmail.com>
Fri, 6 May 2022 15:05:03 +0000 (18:05 +0300)
committerMatthias Clasen <mclasen@redhat.com>
Sat, 7 May 2022 14:31:22 +0000 (10:31 -0400)
This is a hot path when scrolling a ColumnView, and
g_param_spec_pool_lookup () was taking a measurable part in this hot
path. Instead, notify using pspecs to avoid the name lookup.

Related: https://gitlab.gnome.org/GNOME/gtk/-/issues/3334

gtk/gtklistitem.c
gtk/gtklistitemprivate.h
gtk/gtklistitemwidget.c

index b4371b8c932b77b7d1d4d6f3aa98355b8d485701..47fed45058bc5d016ff6d757f567fc39181f7e34 100644 (file)
@@ -247,6 +247,22 @@ gtk_list_item_new (void)
   return g_object_new (GTK_TYPE_LIST_ITEM, NULL);
 }
 
+void
+gtk_list_item_do_notify (GtkListItem *list_item,
+                         gboolean notify_item,
+                         gboolean notify_position,
+                         gboolean notify_selected)
+{
+  GObject *object = G_OBJECT (list_item);
+
+  if (notify_item)
+    g_object_notify_by_pspec (object, properties[PROP_ITEM]);
+  if (notify_position)
+    g_object_notify_by_pspec (object, properties[PROP_POSITION]);
+  if (notify_selected)
+    g_object_notify_by_pspec (object, properties[PROP_SELECTED]);
+}
+
 /**
  * gtk_list_item_get_item: (attributes org.gtk.Method.get_property=item)
  * @self: a `GtkListItem`
index d8f8833313c782356255ce607f7bffc658966856..af8cdd4c943e108e42d1f71840b12a0937767ec9 100644 (file)
@@ -40,6 +40,11 @@ struct _GtkListItem
 
 GtkListItem *   gtk_list_item_new                               (void);
 
+void            gtk_list_item_do_notify                         (GtkListItem *list_item,
+                                                                 gboolean notify_item,
+                                                                 gboolean notify_position,
+                                                                 gboolean notify_selected);
+
 
 G_END_DECLS
 
index 5ef1d357b75ba1a664c650961d80772c17f29982..56f807cf70c7bbeebcf40a23f3ec50cca88e9cf8 100644 (file)
@@ -576,14 +576,7 @@ gtk_list_item_widget_default_update (GtkListItemWidget *self,
     }
 
   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");
-    }
+    gtk_list_item_do_notify (list_item, notify_item, notify_position, notify_selected);
 }
 
 void