[PATCH 2/3] core: fix when no slow/writable keys available
- From: Víctor Manuel Jáquez Leal <vjaquez igalia com>
- To: grilo-list gnome org
- Subject: [PATCH 2/3] core: fix when no slow/writable keys available
- Date: Fri, 22 Oct 2010 18:31:51 +0200
When the source doesn't have slow/writable keys (empty set) the key list is
not filtered. Also, that code is repeated in each filter type.
This patch set to NULL the filtered key list, and the returned complement is
the passed key list. The code is isolated in the generic_filter() too.
Finally, added a description of the function.
Signed-off-by: Víctor Manuel Jáquez Leal <vjaquez igalia com>
---
src/grl-metadata-source.c | 31 +++++++++++++++++--------------
1 files changed, 17 insertions(+), 14 deletions(-)
diff --git a/src/grl-metadata-source.c b/src/grl-metadata-source.c
index 8395dbf..3d9625d 100644
--- a/src/grl-metadata-source.c
+++ b/src/grl-metadata-source.c
@@ -497,6 +497,15 @@ analyze_keys_to_write (GrlMetadataSource *source,
return maps;
}
+/**
+ * This method will _intersect two key lists_:
+ *
+ * @keys_to_filter: user provided set we want to filter leaving only the keys that
+ * intersects with the @source_keys set.
+ * @source_keys: the %GrlMetadataSource<!-- -->'s key set
+ * if @return_filtered is %TRUE a copy of the filtered set *complement* will be
+ * returned (a list of the filtered out keys).
+ */
static GList *
generic_filter (GrlMetadataSource *source,
GList **keys_to_filter,
@@ -509,6 +518,13 @@ generic_filter (GrlMetadataSource *source,
gboolean got_match;
GrlKeyID filtered_key;
+ if (!source_keys) {
+ if (return_filtered)
+ filtered_keys = *keys_to_filter;
+ *keys_to_filter = NULL;
+ goto end_func;
+ }
+
iter_source_keys = (GList *) source_keys;
while (iter_source_keys) {
got_match = FALSE;
@@ -535,6 +551,7 @@ generic_filter (GrlMetadataSource *source,
}
}
+end_func:
return filtered_keys;
}
@@ -794,13 +811,6 @@ grl_metadata_source_filter_slow (GrlMetadataSource *source,
g_return_val_if_fail (GRL_IS_METADATA_SOURCE (source), NULL);
slow_keys = grl_metadata_source_slow_keys (source);
- if (!slow_keys) {
- if (return_filtered) {
- return g_list_copy (*keys);
- } else {
- return NULL;
- }
- }
return generic_filter (source, keys, return_filtered, slow_keys);
}
@@ -831,13 +841,6 @@ grl_metadata_source_filter_writable (GrlMetadataSource *source,
g_return_val_if_fail (keys != NULL, NULL);
writable_keys = grl_metadata_source_writable_keys (source);
- if (!writable_keys) {
- if (return_filtered) {
- return g_list_copy (*keys);
- } else {
- return NULL;
- }
- }
return generic_filter (source, keys, return_filtered, writable_keys);
}
--
1.7.1
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]