From 8ffdbb55d99ffe0f05dcfd27fe6163f894cd8266 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Thu, 13 Feb 2025 18:57:04 +0000 Subject: [PATCH] gfilemonitor: Install properties all at once This is a minor performance improvement, since the pspec list for the class now only has to be modified once, rather than twice. It also means we now have the `GParamSpec` pointers to hand in a `props` array, which will be used in the upcoming commits. Signed-off-by: Philip Withnall --- gio/gfilemonitor.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/gio/gfilemonitor.c b/gio/gfilemonitor.c index ebb9e6fdb..e3028935b 100644 --- a/gio/gfilemonitor.c +++ b/gio/gfilemonitor.c @@ -70,6 +70,7 @@ typedef enum PROP_CANCELLED } GFileMonitorProperty; +static GParamSpec *props[PROP_CANCELLED + 1]; static guint g_file_monitor_changed_signal; static void @@ -200,19 +201,21 @@ g_file_monitor_class_init (GFileMonitorClass *klass) * * The limit of the monitor to watch for changes, in milliseconds. */ - g_object_class_install_property (object_class, PROP_RATE_LIMIT, - g_param_spec_int ("rate-limit", NULL, NULL, - 0, G_MAXINT, DEFAULT_RATE_LIMIT_MSECS, G_PARAM_READWRITE | - G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS)); + props[PROP_RATE_LIMIT] = + g_param_spec_int ("rate-limit", NULL, NULL, + 0, G_MAXINT, DEFAULT_RATE_LIMIT_MSECS, G_PARAM_READWRITE | + G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS); /** * GFileMonitor:cancelled: * * Whether the monitor has been cancelled. */ - g_object_class_install_property (object_class, PROP_CANCELLED, - g_param_spec_boolean ("cancelled", NULL, NULL, - FALSE, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); + props[PROP_CANCELLED] = + g_param_spec_boolean ("cancelled", NULL, NULL, + FALSE, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + + g_object_class_install_properties (object_class, G_N_ELEMENTS (props), props); } /**