From 288eae91e2d7e5547e4d5a3ad305d4a4b8c7b0ef Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Fri, 18 Dec 2009 12:29:25 -0500 Subject: [PATCH] [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 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/shell-app-system.c b/src/shell-app-system.c index ffe3ccc2a..ab609ec1f 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); }