[gnome-shell] [ShellAppSystem] Initialize collation keys for info on-demand



commit 288eae91e2d7e5547e4d5a3ad305d4a4b8c7b0ef
Author: Colin Walters <walters verbum org>
Date:   Fri Dec 18 12:29:25 2009 -0500

    [ShellAppSystem] Initialize collation keys for info on-demand
    
    In case of duplicate infos structures with the same id, the
    info structures we get from looking up the id in app_id_to_info
    aren't necessarily the same as those we used to match, so we
    can't rely on matching to implicitly initialize info->casefolded_name.
    
    Since the name collation key isn't used in matching results,
    just in sorting, init it on-demand in the sorting which is also more
    efficient.

 src/shell-app-system.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
---
diff --git a/src/shell-app-system.c b/src/shell-app-system.c
index ffe3ccc..ab609ec 100644
--- a/src/shell-app-system.c
+++ b/src/shell-app-system.c
@@ -622,7 +622,6 @@ shell_app_info_init_search_data (ShellAppInfo *info)
 
   name = gmenu_tree_entry_get_name ((GMenuTreeEntry*)info->entry);
   info->casefolded_name = normalize_and_casefold (name);
-  info->name_collation_key = g_utf8_collate_key (name, -1);
 
   comment = gmenu_tree_entry_get_comment ((GMenuTreeEntry*)info->entry);
   info->casefolded_description = normalize_and_casefold (comment);
@@ -675,6 +674,11 @@ shell_app_info_compare (gconstpointer a,
   ShellAppInfo *info_a = g_hash_table_lookup (system->priv->app_id_to_info, id_a);
   ShellAppInfo *info_b = g_hash_table_lookup (system->priv->app_id_to_info, id_b);
 
+  if (!info_a->name_collation_key)
+    info_a->name_collation_key = g_utf8_collate_key (gmenu_tree_entry_get_name ((GMenuTreeEntry*)info_a->entry), -1);
+  if (!info_b->name_collation_key)
+    info_b->name_collation_key = g_utf8_collate_key (gmenu_tree_entry_get_name ((GMenuTreeEntry*)info_b->entry), -1);
+
   return strcmp (info_a->name_collation_key, info_b->name_collation_key);
 }
 



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