From 0dad52f7741726f0cd7917f9ad521a77bd50eb31 Mon Sep 17 00:00:00 2001 From: George Kiagiadakis Date: Fri, 31 Oct 2025 18:52:03 +0200 Subject: [PATCH] event-hook: simplify interest matching We never use the feature of matching the subject type, so we can make this simpler by not specifying CHECK_ALL, which also allows the match_full() function to return early if some constraint doesn't match instead of checking them all and wasting time. --- lib/wp/event-hook.c | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/lib/wp/event-hook.c b/lib/wp/event-hook.c index e874a21f..d1e04049 100644 --- a/lib/wp/event-hook.c +++ b/lib/wp/event-hook.c @@ -321,32 +321,15 @@ wp_interest_event_hook_runs_for_event (WpEventHook * hook, WpEvent * event) wp_interest_event_hook_get_instance_private (self); g_autoptr (WpProperties) properties = wp_event_get_properties (event); g_autoptr (GObject) subject = wp_event_get_subject (event); - GType gtype = subject ? G_OBJECT_TYPE (subject) : WP_TYPE_EVENT; guint i; WpObjectInterest *interest = NULL; - WpInterestMatch match; - - const unsigned int MATCH_ALL_PROPS = (WP_INTEREST_MATCH_PW_GLOBAL_PROPERTIES | - WP_INTEREST_MATCH_PW_PROPERTIES | - WP_INTEREST_MATCH_G_PROPERTIES); for (i = 0; i < priv->interests->len; i++) { interest = g_ptr_array_index (priv->interests, i); - match = wp_object_interest_matches_full (interest, - WP_INTEREST_MATCH_FLAGS_CHECK_ALL, - gtype, subject, properties, properties); - - /* the interest may have a GType that matches the GType of the subject - or it may have WP_TYPE_EVENT as its GType, in which case it will - match any type of subject */ - if (match == WP_INTEREST_MATCH_ALL) - return TRUE; - else if (subject && (match & MATCH_ALL_PROPS) == MATCH_ALL_PROPS) { - match = wp_object_interest_matches_full (interest, 0, - WP_TYPE_EVENT, NULL, NULL, NULL); - if (match & WP_INTEREST_MATCH_GTYPE) + if (wp_object_interest_matches_full (interest, + WP_INTEREST_MATCH_FLAGS_NONE, + WP_TYPE_EVENT, subject, properties, properties) == WP_INTEREST_MATCH_ALL) return TRUE; - } } return FALSE; }