[gnome-builder/gnome-builder-41] search: fix search result ordering
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/gnome-builder-41] search: fix search result ordering
- Date: Thu, 14 Oct 2021 21:38:35 +0000 (UTC)
commit 29a82f11dba7c7c4e153c72f8ac9016aa008f02a
Author: Christian Hergert <chergert redhat com>
Date: Thu Oct 14 14:38:15 2021 -0700
search: fix search result ordering
Fixes #190
src/libide/search/ide-search-result.c | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
---
diff --git a/src/libide/search/ide-search-result.c b/src/libide/search/ide-search-result.c
index ce3b44141..731bbe736 100644
--- a/src/libide/search/ide-search-result.c
+++ b/src/libide/search/ide-search-result.c
@@ -165,19 +165,18 @@ ide_search_result_compare (gconstpointer a,
IdeSearchResult *rb = (IdeSearchResult *)b;
IdeSearchResultPrivate *priva = ide_search_result_get_instance_private (ra);
IdeSearchResultPrivate *privb = ide_search_result_get_instance_private (rb);
- gint ret;
- ret = priva->priority - privb->priority;
+ if (priva->priority < privb->priority)
+ return -1;
+ else if (priva->priority > privb->priority)
+ return 1;
- if (ret == 0)
- {
- if (priva->score < privb->score)
- ret = -1;
- else if (priva->score > privb->score)
- ret = 1;
- }
+ if (priva->score > privb->score)
+ return -1;
+ else if (priva->score < privb->score)
+ return 1;
- return ret;
+ return 0;
}
gfloat
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]