From 0112c7fcfd90722259a344d16c42dd069990ec97 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 21 May 2024 03:10:20 -1000 Subject: [PATCH] Small speed up to logbook humanify (#117854) --- homeassistant/components/logbook/processor.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/logbook/processor.py b/homeassistant/components/logbook/processor.py index f617c8e7d73..e25faf090b6 100644 --- a/homeassistant/components/logbook/processor.py +++ b/homeassistant/components/logbook/processor.py @@ -204,13 +204,12 @@ def _humanify( include_entity_name = logbook_run.include_entity_name format_time = logbook_run.format_time memoize_new_contexts = logbook_run.memoize_new_contexts - memoize_context = context_lookup.setdefault # Process rows for row in rows: context_id_bin: bytes = row.context_id_bin - if memoize_new_contexts: - memoize_context(context_id_bin, row) + if memoize_new_contexts and context_id_bin not in context_lookup: + context_lookup[context_id_bin] = row if row.context_only: continue event_type = row.event_type