[glib/wip/notify-performance: 6/11] [notify] lift some logic out of _notify_queue_add
- From: Ryan Lortie <ryanl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/notify-performance: 6/11] [notify] lift some logic out of _notify_queue_add
- Date: Wed, 16 Nov 2011 15:49:36 +0000 (UTC)
commit b72b957ca08d4b413c23526e189431981a97b554
Author: Ryan Lortie <desrt desrt ca>
Date: Wed Nov 16 15:38:25 2011 +0000
[notify] lift some logic out of _notify_queue_add
Lift the check-if-READABLE and redirect-target logic from out of
g_object_notify_queue_add() into its own function, get_notify_pspec().
Use that function at the site of our two calls to
g_object_notify_queue_add().
gobject/gobject.c | 63 +++++++++++++++++++++++++++++++++++-----------------
1 files changed, 42 insertions(+), 21 deletions(-)
---
diff --git a/gobject/gobject.c b/gobject/gobject.c
index 19599cb..6cf93a3 100644
--- a/gobject/gobject.c
+++ b/gobject/gobject.c
@@ -309,26 +309,17 @@ g_object_notify_queue_add (GObject *object,
GObjectNotifyQueue *nqueue,
GParamSpec *pspec)
{
- if (pspec->flags & G_PARAM_READABLE)
- {
- GParamSpec *redirect;
-
- redirect = g_param_spec_get_redirect_target (pspec);
- if (redirect)
- pspec = redirect;
-
- G_LOCK(notify_lock);
+ G_LOCK(notify_lock);
- g_return_if_fail (nqueue->n_pspecs < 65535);
+ g_return_if_fail (nqueue->n_pspecs < 65535);
- if (g_slist_find (nqueue->pspecs, pspec) == NULL)
- {
- nqueue->pspecs = g_slist_prepend (nqueue->pspecs, pspec);
- nqueue->n_pspecs++;
- }
-
- G_UNLOCK(notify_lock);
+ if (g_slist_find (nqueue->pspecs, pspec) == NULL)
+ {
+ nqueue->pspecs = g_slist_prepend (nqueue->pspecs, pspec);
+ nqueue->n_pspecs++;
}
+
+ G_UNLOCK(notify_lock);
}
static void
@@ -1094,15 +1085,39 @@ g_object_freeze_notify (GObject *object)
g_object_unref (object);
}
+static GParamSpec *
+get_notify_pspec (GParamSpec *pspec)
+{
+ GParamSpec *redirected;
+
+ /* we don't notify on non-READABLE parameters */
+ if (~pspec->flags & G_PARAM_READABLE)
+ return NULL;
+
+ /* if the paramspec is redirected, notify on the target */
+ redirected = g_param_spec_get_redirect_target (pspec);
+ if (redirected != NULL)
+ return redirected;
+
+ /* else, notify normally */
+ return pspec;
+}
+
static inline void
g_object_notify_by_spec_internal (GObject *object,
GParamSpec *pspec)
{
GObjectNotifyQueue *nqueue;
+ GParamSpec *notify_pspec;
- nqueue = g_object_notify_queue_freeze (object, &property_notify_context);
- g_object_notify_queue_add (object, nqueue, pspec);
- g_object_notify_queue_thaw (object, nqueue);
+ notify_pspec = get_notify_pspec (pspec);
+
+ if (notify_pspec != NULL)
+ {
+ nqueue = g_object_notify_queue_freeze (object, &property_notify_context);
+ g_object_notify_queue_add (object, nqueue, notify_pspec);
+ g_object_notify_queue_thaw (object, nqueue);
+ }
}
/**
@@ -1318,8 +1333,14 @@ object_set_property (GObject *object,
}
else
{
+ GParamSpec *notify_pspec;
+
class->set_property (object, param_id, &tmp_value, pspec);
- g_object_notify_queue_add (object, nqueue, pspec);
+
+ notify_pspec = get_notify_pspec (pspec);
+
+ if (notify_pspec != NULL)
+ g_object_notify_queue_add (object, nqueue, notify_pspec);
}
g_value_unset (&tmp_value);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]