policy/transmission: don't iterate subject names if the name policy is empty
In the common case of receive policies being empty, let's not iterate
all the names of the sender unneccessarily.
@@ -587,6 +587,9 @@ int transmission_policy_check_allowed(TransmissionPolicy *policy, NameOwner *sub
const char *interface, const char *member, const char *path, int type) {
PolicyDecision decision = {};
+ transmission_policy_update_decision(&policy->wildcard_entry_list, interface, member, path, type, &decision);
+
+ if (!c_rbtree_is_empty(&policy->policy_by_name_tree)) {
if (subject) {
NameOwnership *ownership;
@@ -604,8 +607,7 @@ int transmission_policy_check_allowed(TransmissionPolicy *policy, NameOwner *sub
interface, member, path, type,
&decision);
}
-
- transmission_policy_update_decision(&policy->wildcard_entry_list, interface, member, path, type, &decision);
+ }
return decision.deny ? POLICY_E_ACCESS_DENIED : 0;
}
