Skip to content

Commit

Permalink
match: restructure the match function
Browse files Browse the repository at this point in the history
Move the checks on the keys that are very likely to match last.

Signed-off-by: Tom Gundersen <[email protected]>
  • Loading branch information
teg committed Jan 29, 2018
1 parent dee3380 commit f8a35d2
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/bus/match.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,15 +290,6 @@ static bool match_string_prefix(const char *string, const char *prefix, char del
}

static bool match_keys_match_filter(MatchKeys *keys, MatchFilter *filter) {
if (keys->filter.type != DBUS_MESSAGE_TYPE_INVALID && keys->filter.type != filter->type)
return false;

if (keys->filter.destination != ADDRESS_ID_INVALID && keys->filter.destination != filter->destination)
return false;

if (keys->filter.sender != ADDRESS_ID_INVALID && keys->filter.sender != filter->sender)
return false;

if (keys->filter.interface && !c_string_equal(keys->filter.interface, filter->interface))
return false;

Expand Down Expand Up @@ -326,6 +317,15 @@ static bool match_keys_match_filter(MatchKeys *keys, MatchFilter *filter) {
}
}

if (keys->filter.type != DBUS_MESSAGE_TYPE_INVALID && keys->filter.type != filter->type)
return false;

if (keys->filter.destination != ADDRESS_ID_INVALID && keys->filter.destination != filter->destination)
return false;

if (keys->filter.sender != ADDRESS_ID_INVALID && keys->filter.sender != filter->sender)
return false;

return true;
}

Expand Down

0 comments on commit f8a35d2

Please sign in to comment.