[gnome-shell] shell-app: Remove MATCH_MULTIPLE_{PREFIX,SUFFIX}



commit aee3c6f041cad21d1588f2ba734c6b6862dd920c
Author: Florian MÃllner <fmuellner gnome org>
Date:   Thu Oct 6 01:07:29 2011 +0200

    shell-app: Remove MATCH_MULTIPLE_{PREFIX,SUFFIX}
    
    We originally OR'ed search terms and favored results which matched
    multiple times to get more relevant results. When changing search
    to AND search terms, the semantics of "multiple matches" were
    changed to refer to a single term matching multiple criteria (name,
    executable), which seemed like a good idea at the time.
    
    However in practice this just results in applications whose
    user-visible name matches the executable name on disk being
    favored over applications using a more generic name, which
    isn't too useful (in particular when taking usage frequency
    into account).
    
    https://bugzilla.gnome.org/show_bug.cgi?id=623372

 src/shell-app-private.h |    2 --
 src/shell-app-system.c  |   27 +++++++--------------------
 src/shell-app.c         |   19 +++----------------
 3 files changed, 10 insertions(+), 38 deletions(-)
---
diff --git a/src/shell-app-private.h b/src/shell-app-private.h
index 86dc922..8c6432e 100644
--- a/src/shell-app-private.h
+++ b/src/shell-app-private.h
@@ -24,9 +24,7 @@ void _shell_app_remove_window (ShellApp *app, MetaWindow *window);
 
 void _shell_app_do_match (ShellApp         *app,
                           GSList           *terms,
-                          GSList          **multiple_prefix_results,
                           GSList          **prefix_results,
-                          GSList          **multiple_substring_results,
                           GSList          **substring_results);
 
 G_END_DECLS
diff --git a/src/shell-app-system.c b/src/shell-app-system.c
index e9de0db..0639ad8 100644
--- a/src/shell-app-system.c
+++ b/src/shell-app-system.c
@@ -685,24 +685,16 @@ compare_apps_by_usage (gconstpointer a,
 
 static GSList *
 sort_and_concat_results (ShellAppSystem *system,
-                         GSList         *multiple_prefix_matches,
                          GSList         *prefix_matches,
-                         GSList         *multiple_substring_matches,
                          GSList         *substring_matches)
 {
-  multiple_prefix_matches = g_slist_sort_with_data (multiple_prefix_matches,
-                                                    compare_apps_by_usage,
-                                                    system);
   prefix_matches = g_slist_sort_with_data (prefix_matches,
                                            compare_apps_by_usage,
                                            system);
-  multiple_substring_matches = g_slist_sort_with_data (multiple_substring_matches,
-                                                       compare_apps_by_usage,
-                                                       system);
   substring_matches = g_slist_sort_with_data (substring_matches,
                                               compare_apps_by_usage,
                                               system);
-  return g_slist_concat (multiple_prefix_matches, g_slist_concat (prefix_matches, g_slist_concat (multiple_substring_matches, substring_matches)));
+  return g_slist_concat (prefix_matches, substring_matches);
 }
 
 /**
@@ -729,9 +721,7 @@ search_tree (ShellAppSystem *self,
              GSList         *terms,
              GHashTable     *apps)
 {
-  GSList *multiple_prefix_results = NULL;
   GSList *prefix_results = NULL;
-  GSList *multiple_subtring_results = NULL;
   GSList *substring_results = NULL;
   GSList *normalized_terms;
   GHashTableIter iter;
@@ -746,14 +736,13 @@ search_tree (ShellAppSystem *self,
       ShellApp *app = value;
       (void)id;
       _shell_app_do_match (app, normalized_terms,
-                           &multiple_prefix_results, &prefix_results,
-                           &multiple_subtring_results, &substring_results);
+                           &prefix_results,
+                           &substring_results);
     }
   g_slist_foreach (normalized_terms, (GFunc)g_free, NULL);
   g_slist_free (normalized_terms);
 
-  return sort_and_concat_results (self, multiple_prefix_results, prefix_results,
-                                  multiple_subtring_results, substring_results);
+  return sort_and_concat_results (self, prefix_results, substring_results);
 
 }
 
@@ -792,9 +781,7 @@ shell_app_system_subsearch (ShellAppSystem   *system,
                             GSList           *terms)
 {
   GSList *iter;
-  GSList *multiple_prefix_results = NULL;
   GSList *prefix_results = NULL;
-  GSList *multiple_substring_results = NULL;
   GSList *substring_results = NULL;
   GSList *normalized_terms = normalize_terms (terms);
 
@@ -803,8 +790,8 @@ shell_app_system_subsearch (ShellAppSystem   *system,
       ShellApp *app = iter->data;
       
       _shell_app_do_match (app, normalized_terms,
-                           &multiple_prefix_results, &prefix_results,
-                           &multiple_substring_results, &substring_results);
+                           &prefix_results,
+                           &substring_results);
     }
   g_slist_foreach (normalized_terms, (GFunc)g_free, NULL);
   g_slist_free (normalized_terms);
@@ -812,7 +799,7 @@ shell_app_system_subsearch (ShellAppSystem   *system,
   /* Note that a shorter term might have matched as a prefix, but
      when extended only as a substring, so we have to redo the
      sort rather than reusing the existing ordering */
-  return sort_and_concat_results (system, multiple_prefix_results, prefix_results, multiple_substring_results, substring_results);
+  return sort_and_concat_results (system, prefix_results, substring_results);
 }
 
 /**
diff --git a/src/shell-app.c b/src/shell-app.c
index e6e31df..e0e957e 100644
--- a/src/shell-app.c
+++ b/src/shell-app.c
@@ -19,9 +19,7 @@
 typedef enum {
   MATCH_NONE,
   MATCH_SUBSTRING, /* Not prefix, substring */
-  MATCH_MULTIPLE_SUBSTRING, /* Matches multiple criteria with substrings */
   MATCH_PREFIX, /* Strict prefix */
-  MATCH_MULTIPLE_PREFIX, /* Matches multiple criteria, at least one prefix */
 } ShellAppSearchMatch;
 
 /* This is mainly a memory usage optimization - the user is going to
@@ -1267,11 +1265,9 @@ _shell_app_match_search_terms (ShellApp  *app,
       if (p != NULL)
         {
           if (p == app->casefolded_exec || *(p - 1) == '-')
-            current_match = (current_match == MATCH_NONE) ? MATCH_PREFIX
-                                                          : MATCH_MULTIPLE_PREFIX;
+            current_match = MATCH_PREFIX;
           else if (current_match < MATCH_PREFIX)
-            current_match = (current_match == MATCH_NONE) ? MATCH_SUBSTRING
-                                                          : MATCH_MULTIPLE_SUBSTRING;
+            current_match = MATCH_SUBSTRING;
         }
 
       if (app->casefolded_description && current_match < MATCH_PREFIX)
@@ -1281,8 +1277,7 @@ _shell_app_match_search_terms (ShellApp  *app,
            */
           p = strstr (app->casefolded_description, term);
           if (p != NULL)
-            current_match = (current_match == MATCH_NONE) ? MATCH_SUBSTRING
-                                                          : MATCH_MULTIPLE_SUBSTRING;
+            current_match = MATCH_SUBSTRING;
         }
 
       if (current_match == MATCH_NONE)
@@ -1297,9 +1292,7 @@ _shell_app_match_search_terms (ShellApp  *app,
 void
 _shell_app_do_match (ShellApp         *app,
                      GSList           *terms,
-                     GSList          **multiple_prefix_results,
                      GSList          **prefix_results,
-                     GSList          **multiple_substring_results,
                      GSList          **substring_results)
 {
   ShellAppSearchMatch match;
@@ -1320,15 +1313,9 @@ _shell_app_do_match (ShellApp         *app,
     {
       case MATCH_NONE:
         break;
-      case MATCH_MULTIPLE_PREFIX:
-        *multiple_prefix_results = g_slist_prepend (*multiple_prefix_results, app);
-        break;
       case MATCH_PREFIX:
         *prefix_results = g_slist_prepend (*prefix_results, app);
         break;
-      case MATCH_MULTIPLE_SUBSTRING:
-        *multiple_substring_results = g_slist_prepend (*multiple_substring_results, app);
-        break;
       case MATCH_SUBSTRING:
         *substring_results = g_slist_prepend (*substring_results, app);
         break;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]