From 73617ec7fa7a63361b931c5a26d14710779cbd7d Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Sun, 1 Mar 2026 19:36:42 +0100 Subject: [PATCH] perf: fast-path length check in StatusHistory comparison (#22103) Add O(1) array length check before expensive JSON.stringify comparison. During streaming, status history typically only grows via appends, so a length mismatch catches most updates without serialization. --- .../chat/Messages/ResponseMessage/StatusHistory.svelte | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib/components/chat/Messages/ResponseMessage/StatusHistory.svelte b/src/lib/components/chat/Messages/ResponseMessage/StatusHistory.svelte index c3c62af3c..8497f0b2c 100644 --- a/src/lib/components/chat/Messages/ResponseMessage/StatusHistory.svelte +++ b/src/lib/components/chat/Messages/ResponseMessage/StatusHistory.svelte @@ -21,7 +21,8 @@ status = history.at(-1); } - $: if (JSON.stringify(statusHistory) !== JSON.stringify(history)) { + $: if (statusHistory.length !== history.length + || JSON.stringify(statusHistory) !== JSON.stringify(history)) { history = statusHistory; }