Speed up ssdp domain matching (#124842)
* Speed up ssdp domain matching Switch all() expression to dict.items() <= dict.items() * rewrite as setcomp
This commit is contained in:
parent
69a9aa4594
commit
6781a76de2
1 changed files with 7 additions and 10 deletions
|
@ -284,16 +284,13 @@ class IntegrationMatchers:
|
|||
def async_matching_domains(self, info_with_desc: CaseInsensitiveDict) -> set[str]:
|
||||
"""Find domains matching the passed CaseInsensitiveDict."""
|
||||
assert self._match_by_key is not None
|
||||
domains = set()
|
||||
for key, matchers_by_key in self._match_by_key.items():
|
||||
if not (match_value := info_with_desc.get(key)):
|
||||
continue
|
||||
for domain, matcher in matchers_by_key.get(match_value, []):
|
||||
if domain in domains:
|
||||
continue
|
||||
if all(info_with_desc.get(k) == v for (k, v) in matcher.items()):
|
||||
domains.add(domain)
|
||||
return domains
|
||||
return {
|
||||
domain
|
||||
for key, matchers_by_key in self._match_by_key.items()
|
||||
if (match_value := info_with_desc.get(key))
|
||||
for domain, matcher in matchers_by_key.get(match_value, ())
|
||||
if info_with_desc.items() >= matcher.items()
|
||||
}
|
||||
|
||||
|
||||
class Scanner:
|
||||
|
|
Loading…
Add table
Reference in a new issue