Small speedup to processing entity customize (#121271)

This commit is contained in:
J. Nick Koston 2024-07-05 01:57:08 -05:00 committed by GitHub
parent cdb2ec4231
commit e71f6c5948
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1185,11 +1185,18 @@ class Entity(
report_issue, report_issue,
) )
# Overwrite properties that have been set in the config file. try:
if (customize := hass.data.get(DATA_CUSTOMIZE)) and ( # Most of the time this will already be
custom := customize.get(entity_id) # set and since try is near zero cost
): # on py3.11+ its faster to assume it is
attr.update(custom) # set and catch the exception if it is not.
customize = hass.data[DATA_CUSTOMIZE]
except KeyError:
pass
else:
# Overwrite properties that have been set in the config file.
if custom := customize.get(entity_id):
attr.update(custom)
if ( if (
self._context_set is not None self._context_set is not None