Replace the compareByteArrays functions, in src/core/crypto.js, with the isArrayEqual helper function

The `compareByteArrays` is first of all duplicated in multiple closures in the `src/core/crypto.js` file. Secondly, despite its name, it's also functionally equivalent to the now existing `isArrayEqual` helper function.

The `isArrayEqual` helper function is changed to use a standard `for`-loop, rather than `Array.prototype.every`, since that ought to be slightly more efficient given that we're now using it with (potentially) larger data.
This commit is contained in:
Jonas Jenwald 2021-02-26 15:51:32 +01:00
parent 061637d3f4
commit 9a9a5b2365
2 changed files with 11 additions and 31 deletions

View file

@ -884,9 +884,12 @@ function isArrayEqual(arr1, arr2) {
if (arr1.length !== arr2.length) {
return false;
}
return arr1.every(function (element, index) {
return element === arr2[index];
});
for (let i = 0, ii = arr1.length; i < ii; i++) {
if (arr1[i] !== arr2[i]) {
return false;
}
}
return true;
}
function getModificationDate(date = new Date()) {