From c53aa89098e4369b13e87f9c5f5ab173f0b40ef4 Mon Sep 17 00:00:00 2001 From: Olivier Fourdan Date: Thu, 16 May 2019 10:58:27 +0200 Subject: [PATCH] keybindings: Small code cleanup Reuse the name we just set to insert in the hash table, that avoids duplicating the string. Suggested-by: Carlos Garnacho https://gitlab.gnome.org/GNOME/mutter/merge_requests/453 --- src/core/keybindings.c | 8 ++++---- src/core/prefs.c | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/core/keybindings.c b/src/core/keybindings.c index 8e73ce921..4e8493211 100644 --- a/src/core/keybindings.c +++ b/src/core/keybindings.c @@ -4455,26 +4455,26 @@ meta_display_init_keys (MetaDisplay *display) handler->name = g_strdup ("overlay-key"); handler->flags = META_KEY_BINDING_BUILTIN; - g_hash_table_insert (key_handlers, g_strdup ("overlay-key"), handler); + g_hash_table_insert (key_handlers, g_strdup (handler->name), handler); handler = g_new0 (MetaKeyHandler, 1); handler->name = g_strdup ("locate-pointer-key"); handler->flags = META_KEY_BINDING_BUILTIN; - g_hash_table_insert (key_handlers, g_strdup ("locate-pointer-key"), handler); + g_hash_table_insert (key_handlers, g_strdup (handler->name), handler); handler = g_new0 (MetaKeyHandler, 1); handler->name = g_strdup ("iso-next-group"); handler->flags = META_KEY_BINDING_BUILTIN; - g_hash_table_insert (key_handlers, g_strdup ("iso-next-group"), handler); + g_hash_table_insert (key_handlers, g_strdup (handler->name), handler); handler = g_new0 (MetaKeyHandler, 1); handler->name = g_strdup ("external-grab"); handler->func = handle_external_grab; handler->default_func = handle_external_grab; - g_hash_table_insert (key_handlers, g_strdup ("external-grab"), handler); + g_hash_table_insert (key_handlers, g_strdup (handler->name), handler); external_grabs = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, diff --git a/src/core/prefs.c b/src/core/prefs.c index 9f11a2842..ca503bc3f 100644 --- a/src/core/prefs.c +++ b/src/core/prefs.c @@ -1728,7 +1728,7 @@ init_bindings (void) pref->combos = g_slist_prepend (pref->combos, &overlay_key_combo); pref->builtin = 1; - g_hash_table_insert (key_bindings, g_strdup ("overlay-key"), pref); + g_hash_table_insert (key_bindings, g_strdup (pref->name), pref); pref = g_new0 (MetaKeyPref, 1); pref->name = g_strdup ("locate-pointer-key"); @@ -1736,7 +1736,7 @@ init_bindings (void) pref->combos = g_slist_prepend (pref->combos, &locate_pointer_key_combo); pref->builtin = 1; - g_hash_table_insert (key_bindings, g_strdup ("locate-pointer-key"), pref); + g_hash_table_insert (key_bindings, g_strdup (pref->name), pref); } static gboolean