Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core: refactor diff to do less slow mutations #1697

Merged
merged 2 commits into from Jul 9, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 1 addition & 12 deletions src/core/utilities.js
Expand Up @@ -43,18 +43,7 @@ export const performance = {

// Returns a new Array with the elements that are in a but not in b
export function diff (a, b) {
const result = a.slice();

for (let i = 0; i < result.length; i++) {
for (let j = 0; j < b.length; j++) {
if (result[i] === b[j]) {
result.splice(i, 1);
i--;
break;
}
}
}
return result;
return a.filter((a) => b.indexOf(a) === -1);
}

/**
Expand Down