Skip to content

Commit f7a001d

Browse files
authored
feat: only look up _async_on_advertisement once per advertisement group (#108)
chore: profile ref to async_on_advertisement
1 parent 62bb8bf commit f7a001d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/bleak_esphome/backend/scanner.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ def async_on_raw_advertisements(
3939
"""Call the registered callback."""
4040
now = MONOTONIC_TIME()
4141
advertisements = raw.advertisements
42+
async_on_advertisement = self._async_on_advertisement
4243
# We avoid __iter__ on the protobuf object because
4344
# the the protobuf library has an expensive internal
4445
# debug logging when it reaches the end of a repeated field.
@@ -49,7 +50,7 @@ def async_on_raw_advertisements(
4950
for i in range(len(advertisements)):
5051
adv = advertisements[i]
5152
parsed: tuple = parse_advertisement_data_tuple((adv.data,)) # type: ignore[type-arg]
52-
self._async_on_advertisement(
53+
async_on_advertisement(
5354
int_to_bluetooth_address(adv.address),
5455
adv.rssi,
5556
parsed[0],

0 commit comments

Comments
 (0)