[grilo-plugins] tracker: small rework on _tracker_get_insert_string()
- From: Victor Toso de Carvalho <victortoso src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [grilo-plugins] tracker: small rework on _tracker_get_insert_string()
- Date: Fri, 2 Dec 2016 21:24:16 +0000 (UTC)
commit 9183260dd5b255a323811d4e71475ceb08100141
Author: Victor Toso <me victortoso com>
Date: Mon Nov 21 18:54:13 2016 +0100
tracker: small rework on _tracker_get_insert_string()
Clear a bit the logic so it gets easier to include changes.
This patch does:
- Change GList iteration from while() to for()
- Move variables to its local scope;
- Use *continue* inside the for;
- Remove if else check on gboolean first
https://bugzilla.gnome.org/show_bug.cgi?id=774748
src/tracker/grl-tracker-utils.c | 47 ++++++++++++++++++--------------------
1 files changed, 22 insertions(+), 25 deletions(-)
---
diff --git a/src/tracker/grl-tracker-utils.c b/src/tracker/grl-tracker-utils.c
index 2b97636..fd13041 100644
--- a/src/tracker/grl-tracker-utils.c
+++ b/src/tracker/grl-tracker-utils.c
@@ -489,36 +489,33 @@ gchar *
grl_tracker_tracker_get_insert_string (GrlMedia *media, const GList *keys)
{
gboolean first = TRUE;
- const GList *key = keys, *assoc_list;
- tracker_grl_sparql_t *assoc;
+ const GList *key;
GString *gstr = g_string_new ("");
- gchar *ret;
- while (key != NULL) {
- assoc_list = get_mapping_from_grl (GRLPOINTER_TO_KEYID (key->data));
- while (assoc_list != NULL) {
- assoc = (tracker_grl_sparql_t *) assoc_list->data;
- if (assoc != NULL) {
- if (grl_data_has_key (GRL_DATA (media),
- GRLPOINTER_TO_KEYID (key->data))) {
- if (first) {
- gen_prop_insert_string (gstr, assoc, GRL_DATA (media));
- first = FALSE;
- } else {
- g_string_append (gstr, " ; ");
- gen_prop_insert_string (gstr, assoc, GRL_DATA (media));
- }
- }
- }
- assoc_list = assoc_list->next;
+ for (key = keys; key != NULL; key = key->next) {
+ const GList *assoc_list;
+ GrlKeyID key_id = GRLPOINTER_TO_KEYID (key->data);
+
+ for (assoc_list = get_mapping_from_grl (key_id);
+ assoc_list != NULL;
+ assoc_list = assoc_list->next) {
+ tracker_grl_sparql_t *assoc = assoc_list->data;
+
+ if (assoc == NULL)
+ continue;
+
+ if (!grl_data_has_key (GRL_DATA (media), key_id))
+ continue;
+
+ if (!first)
+ g_string_append (gstr, " ; ");
+
+ gen_prop_insert_string (gstr, assoc, GRL_DATA (media));
+ first = FALSE;
}
- key = key->next;
}
- ret = gstr->str;
- g_string_free (gstr, FALSE);
-
- return ret;
+ return g_string_free (gstr, FALSE);
}
gchar *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]