mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 09:47:13 +00:00
Speed up LazyEventPartialState for logbook (#91840)
* Speed up LazyEventPartialState for logbook We should avoid the getattr call since every row would have to call the sqlalchemy key not found implemention if we blindly getattr * Speed up LazyEventPartialState for logbook We should avoid the getattr call since every row would have to call the sqlalchemy key not found implemention if we blindly getattr
This commit is contained in:
parent
9a0de43f98
commit
2663901603
@ -64,10 +64,12 @@ class LazyEventPartialState:
|
||||
self.context_id_bin: bytes | None = self.row.context_id_bin
|
||||
self.context_user_id_bin: bytes | None = self.row.context_user_id_bin
|
||||
self.context_parent_id_bin: bytes | None = self.row.context_parent_id_bin
|
||||
if data := getattr(row, "data", None):
|
||||
# We need to explicitly check for the row is EventAsRow as the unhappy path
|
||||
# to fetch row.data for Row is very expensive
|
||||
if type(row) is EventAsRow: # pylint: disable=unidiomatic-typecheck
|
||||
# If its an EventAsRow we can avoid the whole
|
||||
# json decode process as we already have the data
|
||||
self.data = data
|
||||
self.data = row.data
|
||||
return
|
||||
source = cast(str, self.row.shared_data or self.row.event_data)
|
||||
if not source:
|
||||
|
Loading…
x
Reference in New Issue
Block a user