[gtk/wip/baedert/for-master] settings: Overallocate property_values



commit 1316da399d1e7343b42368ab4c858b4d911a54c6
Author: Timm Bäder <mail baedert org>
Date:   Thu Dec 31 12:48:41 2020 +0100

    settings: Overallocate property_values
    
    Instead of walking the pspecs twice and checking for the owner_type,
    just allocate n_pspecs entries. They are the same value right now
    anyway, but even if they aren't it doesn't hurt to have a few extra ones
    allocated.

 gtk/gtksettings.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
---
diff --git a/gtk/gtksettings.c b/gtk/gtksettings.c
index 02b02c3911..2338fcf530 100644
--- a/gtk/gtksettings.c
+++ b/gtk/gtksettings.c
@@ -236,6 +236,7 @@ static void
 gtk_settings_init (GtkSettings *settings)
 {
   GParamSpec **pspecs, **p;
+  guint n_pspecs;
   guint i = 0;
   char *path;
   const char * const *config_dirs;
@@ -250,14 +251,11 @@ gtk_settings_init (GtkSettings *settings)
    * notification for them (at least notification for internal properties
    * will instantly be caught)
    */
-  pspecs = g_object_class_list_properties (G_OBJECT_GET_CLASS (settings), NULL);
-  for (p = pspecs; *p; p++)
-    if ((*p)->owner_type == G_OBJECT_TYPE (settings))
-      i++;
-  settings->property_values = g_new0 (GtkSettingsPropertyValue, i);
-  i = 0;
+  pspecs = g_object_class_list_properties (G_OBJECT_GET_CLASS (settings), &n_pspecs);
+  settings->property_values = g_new0 (GtkSettingsPropertyValue, n_pspecs);
   g_object_freeze_notify (G_OBJECT (settings));
 
+  i = 0;
   for (p = pspecs; *p; p++)
     {
       GParamSpec *pspec = *p;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]