summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim-Philipp Müller <tim.muller@collabora.co.uk>2010-09-08 18:41:18 +0100
committerTim-Philipp Müller <tim.muller@collabora.co.uk>2010-09-08 18:51:09 +0100
commitbf2bdba6b391bc1e411b2cf8e25de8dca2ef612b (patch)
tree01319a41d822529c96ccaf217e3c27cda2bdb11d
parent770694f0f126a5cbeddf0fc14bee84bfb82049d9 (diff)
caps: simplify code a bit
No need to call g_slist_length() here.
-rw-r--r--gst/gstcaps.c29
1 files changed, 11 insertions, 18 deletions
diff --git a/gst/gstcaps.c b/gst/gstcaps.c
index 14f9f7477..dd3303e2f 100644
--- a/gst/gstcaps.c
+++ b/gst/gstcaps.c
@@ -1837,24 +1837,17 @@ gst_caps_structure_simplify (GstStructure ** result,
/* try to subtract to get a real subset */
if (gst_caps_structure_subtract (&list, simplify, compare)) {
- switch (g_slist_length (list)) {
- case 0:
- *result = NULL;
- return TRUE;
- case 1:
- *result = list->data;
- g_slist_free (list);
- return TRUE;
- default:
- {
- GSList *walk;
-
- for (walk = list; walk; walk = g_slist_next (walk)) {
- gst_structure_free (walk->data);
- }
- g_slist_free (list);
- break;
- }
+ if (list == NULL) { /* no result */
+ *result = NULL;
+ return TRUE;
+ } else if (list->next == NULL) { /* one result */
+ *result = list->data;
+ g_slist_free (list);
+ return TRUE;
+ } else { /* multiple results */
+ g_slist_foreach (list, (GFunc) gst_structure_free, NULL);
+ g_slist_free (list);
+ list = NULL;
}
}