[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.
This commit is contained in:
Colin Walters 2009-12-18 12:29:25 -05:00
parent f4c05deb2d
commit 288eae91e2

View File

@ -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);
}