inotify: Optimize consecutive g_hash_table_{lookup,remove} calls

This commit is contained in:
Gleb Popov 2024-09-19 10:22:39 +03:00
parent 697118dfd5
commit 30dfc99c94

View File

@ -275,12 +275,10 @@ ik_source_dispatch (GSource *source,
{ {
ik_event_t *pair; ik_event_t *pair;
pair = g_hash_table_lookup (iks->unmatched_moves, GUINT_TO_POINTER (event->cookie)); if (g_hash_table_steal_extended (iks->unmatched_moves, GUINT_TO_POINTER (event->cookie), NULL, (gpointer*)&pair))
if (pair != NULL)
{ {
g_assert (!pair->pair); g_assert (!pair->pair);
g_hash_table_remove (iks->unmatched_moves, GUINT_TO_POINTER (event->cookie));
event->is_second_in_pair = TRUE; event->is_second_in_pair = TRUE;
event->pair = pair; event->pair = pair;
pair->pair = event; pair->pair = event;
@ -344,12 +342,10 @@ ik_source_dispatch (GSource *source,
{ {
ik_event_t *pair; ik_event_t *pair;
pair = g_hash_table_lookup (iks->unmatched_moves, GUINT_TO_POINTER (event->cookie)); if (g_hash_table_steal_extended (iks->unmatched_moves, GUINT_TO_POINTER (event->cookie), NULL, (gpointer*)&pair))
if (pair != NULL)
{ {
g_assert (!pair->pair); g_assert (!pair->pair);
g_hash_table_remove (iks->unmatched_moves, GUINT_TO_POINTER (event->cookie));
event->is_second_in_pair = TRUE; event->is_second_in_pair = TRUE;
event->pair = pair; event->pair = pair;
pair->pair = event; pair->pair = event;