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}`; }