[gnome-software/wip/william/cherry-pick-4: 12/23] De-dup based on source
- From: William Hua <williamhua src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/william/cherry-pick-4: 12/23] De-dup based on source
- Date: Fri, 3 Jun 2016 07:01:31 +0000 (UTC)
commit ee053bee382fe50f232aaf0d3c111d61cce9b86c
Author: Robert Ancell <robert ancell canonical com>
Date: Thu Jun 2 15:41:29 2016 -0400
De-dup based on source
src/gs-app-list.c | 13 ++++++++++---
1 files changed, 10 insertions(+), 3 deletions(-)
---
diff --git a/src/gs-app-list.c b/src/gs-app-list.c
index f0858c1..075ff82 100644
--- a/src/gs-app-list.c
+++ b/src/gs-app-list.c
@@ -258,9 +258,10 @@ gs_app_list_filter_duplicates (GsAppList *list)
{
guint i;
GsApp *app;
- GsApp *found;
- const gchar *id;
+ GsApp *found, *found_source;
+ const gchar *id, *source;
g_autoptr(GHashTable) hash = NULL;
+ g_autoptr(GHashTable) source_hash = NULL;
g_autoptr(GsAppList) old = NULL;
g_return_if_fail (GS_IS_APP_LIST (list));
@@ -271,18 +272,24 @@ gs_app_list_filter_duplicates (GsAppList *list)
/* create a new list with just the unique items */
hash = g_hash_table_new (g_str_hash, g_str_equal);
+ source_hash = g_hash_table_new (g_str_hash, g_str_equal);
for (i = 0; i < old->array->len; i++) {
app = gs_app_list_index (old, i);
id = gs_app_get_id (app);
+ source = gs_app_get_source_default (app);
if (id == NULL) {
gs_app_list_add (list, app);
continue;
}
found = g_hash_table_lookup (hash, id);
- if (found == NULL) {
+ found_source = source != NULL ? g_hash_table_lookup (source_hash, source) : NULL;
+ if (found == NULL && found_source == NULL) {
gs_app_list_add (list, app);
g_hash_table_insert (hash, (gpointer) id,
GUINT_TO_POINTER (1));
+ if (source != NULL)
+ g_hash_table_insert (source_hash, (gpointer) source,
+ GUINT_TO_POINTER (1));
continue;
}
g_debug ("ignoring duplicate %s", id);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]