diff options
author | Benjamin Otte <otte@redhat.com> | 2010-08-06 23:15:28 +0200 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2010-08-06 23:35:24 +0200 |
commit | 4ac7f8f08433c37cf0a69cdea601514a0c06c1b6 (patch) | |
tree | b5ef85c6d259db86626aabdcb88115475a4831da | |
parent | e88eb048659be2e09081a27ddaef0e261667b6b8 (diff) |
notifyqueue: Dedup pspecs when adding2.25.13
The previous code dedup'd when thawing and threw nasty warnings your way
if you notified too often. This can now easily be avoided.
Performance should be roughly identical, as both are O(n²).
-rw-r--r-- | gobject/gobjectnotifyqueue.c | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/gobject/gobjectnotifyqueue.c b/gobject/gobjectnotifyqueue.c index e53e22bfb..8aa148507 100644 --- a/gobject/gobjectnotifyqueue.c +++ b/gobject/gobjectnotifyqueue.c @@ -119,22 +119,10 @@ g_object_notify_queue_thaw (GObject *object, } pspecs = nqueue->n_pspecs > 16 ? free_me = g_new (GParamSpec*, nqueue->n_pspecs) : pspecs_mem; - /* set first entry to NULL since it's checked unconditionally */ - pspecs[0] = NULL; + for (slist = nqueue->pspecs; slist; slist = slist->next) { - GParamSpec *pspec = slist->data; - guint i; - - /* dedup, make pspecs in the list unique */ - for (i = 0; i < n_pspecs; i++) - { - if (pspecs[i] == pspec) - break; - } - - if (i == n_pspecs) /* if no match was found */ - pspecs[n_pspecs++] = pspec; + pspecs[n_pspecs++] = slist->data; } g_datalist_id_set_data (&object->qdata, context->quark_notify_queue, NULL); @@ -178,8 +166,11 @@ g_object_notify_queue_add (GObject *object, pspec = redirect; /* we do the deduping in _thaw */ - nqueue->pspecs = g_slist_prepend (nqueue->pspecs, pspec); - nqueue->n_pspecs++; + if (g_slist_find (nqueue->pspecs, pspec) == NULL) + { + nqueue->pspecs = g_slist_prepend (nqueue->pspecs, pspec); + nqueue->n_pspecs++; + } G_UNLOCK(notify_lock); } |