From 30dfc99c941d4a8081216b4cfb0162c571a1c8e8 Mon Sep 17 00:00:00 2001 From: Gleb Popov <6yearold@gmail.com> Date: Thu, 19 Sep 2024 10:22:39 +0300 Subject: [PATCH] inotify: Optimize consecutive g_hash_table_{lookup,remove} calls --- gio/inotify/inotify-kernel.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/gio/inotify/inotify-kernel.c b/gio/inotify/inotify-kernel.c index 90e001ebe..fc78641db 100644 --- a/gio/inotify/inotify-kernel.c +++ b/gio/inotify/inotify-kernel.c @@ -275,12 +275,10 @@ ik_source_dispatch (GSource *source, { ik_event_t *pair; - pair = g_hash_table_lookup (iks->unmatched_moves, GUINT_TO_POINTER (event->cookie)); - if (pair != NULL) + if (g_hash_table_steal_extended (iks->unmatched_moves, GUINT_TO_POINTER (event->cookie), NULL, (gpointer*)&pair)) { g_assert (!pair->pair); - g_hash_table_remove (iks->unmatched_moves, GUINT_TO_POINTER (event->cookie)); event->is_second_in_pair = TRUE; event->pair = pair; pair->pair = event; @@ -344,12 +342,10 @@ ik_source_dispatch (GSource *source, { ik_event_t *pair; - pair = g_hash_table_lookup (iks->unmatched_moves, GUINT_TO_POINTER (event->cookie)); - if (pair != NULL) + if (g_hash_table_steal_extended (iks->unmatched_moves, GUINT_TO_POINTER (event->cookie), NULL, (gpointer*)&pair)) { g_assert (!pair->pair); - g_hash_table_remove (iks->unmatched_moves, GUINT_TO_POINTER (event->cookie)); event->is_second_in_pair = TRUE; event->pair = pair; pair->pair = event;