[gnome-builder] search: fix search result ordering



commit a4da7132064fa03601bd3de4aba509a5dea72397
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]