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 <pwithnall@gnome.org>
This commit is contained in:
Philip Withnall 2025-02-13 18:57:04 +00:00
parent 5aa42683ee
commit 8ffdbb55d9
No known key found for this signature in database
GPG Key ID: C5C42CFB268637CA

View File

@ -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);
}
/**