mirror of
https://gitlab.freedesktop.org/pipewire/wireplumber.git
synced 2025-12-20 01:50:04 +01:00
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.
This commit is contained in:
parent
27f97f6c45
commit
0dad52f774
1 changed files with 3 additions and 20 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue