mirror of
https://github.com/zen-browser/desktop.git
synced 2025-10-16 23:06:30 +00:00
fix: add timestamp check to prevent frequent array comparisons in arraysEqual
This commit is contained in:
@@ -91,6 +91,7 @@
|
|||||||
|
|
||||||
#excludedUrls = [];
|
#excludedUrls = [];
|
||||||
#compiledExcludedUrls = [];
|
#compiledExcludedUrls = [];
|
||||||
|
#lastCheckedUrlTimestamp = 0;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
@@ -197,12 +198,18 @@
|
|||||||
if (a == null || b == null) return false;
|
if (a == null || b == null) return false;
|
||||||
if (a.length !== b.length) 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
|
// If you don't care about the order of the elements inside
|
||||||
// the array, you should sort both arrays here.
|
// the array, you should sort both arrays here.
|
||||||
// Please note that calling sort on an array will modify that array.
|
// Please note that calling sort on an array will modify that array.
|
||||||
// you might want to clone your array first.
|
// 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;
|
if (a[i] !== b[i]) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
Reference in New Issue
Block a user