From ce7fe9609721d63ab37ff8ae18d94346b18e5f7f Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Thu, 12 Mar 2026 22:22:50 +1100 Subject: [PATCH] networkusage: avoid intermediate array copy for history updates --- services/NetworkUsage.qml | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/services/NetworkUsage.qml b/services/NetworkUsage.qml index 502ec3ae..a9406480 100644 --- a/services/NetworkUsage.qml +++ b/services/NetworkUsage.qml @@ -192,21 +192,13 @@ Singleton { const maxHistory = root.historyLength + 1; if (root._downloadSpeed >= 0 && isFinite(root._downloadSpeed)) { - let newDownHist = root._downloadHistory.slice(); - newDownHist.push(root._downloadSpeed); - if (newDownHist.length > maxHistory) { - newDownHist.shift(); - } - root._downloadHistory = newDownHist; + const dh = root._downloadHistory; + root._downloadHistory = dh.length >= maxHistory ? [...dh.slice(1), root._downloadSpeed] : [...dh, root._downloadSpeed]; } if (root._uploadSpeed >= 0 && isFinite(root._uploadSpeed)) { - let newUpHist = root._uploadHistory.slice(); - newUpHist.push(root._uploadSpeed); - if (newUpHist.length > maxHistory) { - newUpHist.shift(); - } - root._uploadHistory = newUpHist; + const uh = root._uploadHistory; + root._uploadHistory = uh.length >= maxHistory ? [...uh.slice(1), root._uploadSpeed] : [...uh, root._uploadSpeed]; } }