match = tag->type & q->type;
/* Remove tag from the results. tags are unowned so removing is easy */
if (!match)
g_queue_unlink(&res, node);
- }
- /* Convert GQueue to GPtrArray for sort, dedup and return */
- i = 0;
- ret = g_ptr_array_sized_new(g_queue_get_length(&res));
- foreach_list(node, res.head)
- {
tag = (TMTag *) node->data;
g_ptr_array_insert(ret, i++, tag);
- }
- g_list_free(res.head);
There is no need to add in the middle. As mentioned above, sorting before the end looks like a bad idea here, so you end up trading prunning the array with building a list. And prunning the array is basically implemented as a set of pointer moves, not consecutive `memmove()`s.