From d6c30caf1b1f36b86fbd4ce5fe4324b7765fbf8e Mon Sep 17 00:00:00 2001 From: Slowlife01 Date: Sun, 6 Apr 2025 09:22:49 +0700 Subject: [PATCH] fix: add timestamp check to prevent frequent array comparisons in arraysEqual --- src/browser/base/zen-components/ZenTabUnloader.mjs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/browser/base/zen-components/ZenTabUnloader.mjs b/src/browser/base/zen-components/ZenTabUnloader.mjs index 9cec014fa..295013d44 100644 --- a/src/browser/base/zen-components/ZenTabUnloader.mjs +++ b/src/browser/base/zen-components/ZenTabUnloader.mjs @@ -91,6 +91,7 @@ #excludedUrls = []; #compiledExcludedUrls = []; + #lastCheckedUrlTimestamp = 0; constructor() { super(); @@ -197,12 +198,18 @@ if (a == null || b == null) return false; if (a.length !== b.length) return false; + const currentTimestamp = Date.now(); + if (currentTimestamp - this.#lastCheckedUrlTimestamp < 5 * 1000) { + return true; + } + + this.#lastCheckedUrlTimestamp = currentTimestamp; // If you don't care about the order of the elements inside // the array, you should sort both arrays here. // Please note that calling sort on an array will modify that array. // you might want to clone your array first. - for (var i = 0; i < a.length; ++i) { + for (const i = 0; i < a.length; ++i) { if (a[i] !== b[i]) return false; } return true;