From 434f42b4886dce6fc8d599d5409ff3275d573816 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 28 Aug 2026 21:07:25 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=20Bolt:=20Optimize=20time=20formattin?= =?UTF-8?q?g=20with=20pre-computed=20array?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/cli/ui/components/messageList/utils.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/cli/ui/components/messageList/utils.ts b/src/cli/ui/components/messageList/utils.ts index ca9a3ed9..9f04c8d9 100644 --- a/src/cli/ui/components/messageList/utils.ts +++ b/src/cli/ui/components/messageList/utils.ts @@ -1,6 +1,9 @@ +// Expected Impact: Reduces string allocations and padding operations per render cycle +const PADDED_NUMBERS = Array.from({ length: 60 }, (_, i) => String(i).padStart(2, '0')); + export function formatTime(timestamp: Date): string { - const hours = String(timestamp.getHours()).padStart(2, '0'); - const minutes = String(timestamp.getMinutes()).padStart(2, '0'); - const seconds = String(timestamp.getSeconds()).padStart(2, '0'); + const hours = PADDED_NUMBERS[timestamp.getHours()]; + const minutes = PADDED_NUMBERS[timestamp.getMinutes()]; + const seconds = PADDED_NUMBERS[timestamp.getSeconds()]; return `${hours}:${minutes}:${seconds}`; }