Skip to content

Conversation

jacogr
Copy link
Member

@jacogr jacogr commented Jan 22, 2022

No description provided.

Comment on lines +228 to +239
for (let j = 0; j < list.length; j++) {
if (i !== j) {
const [,,, others] = list[j];

for (let a = 1; a < aliases.length; a++) {
const alias = aliases[a];

if (!dupes.includes(alias) && others.includes(alias)) {
dupes.push(alias);
}
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

x2 faster:

Suggested change
for (let j = 0; j < list.length; j++) {
if (i !== j) {
const [,,, others] = list[j];
for (let a = 1; a < aliases.length; a++) {
const alias = aliases[a];
if (!dupes.includes(alias) && others.includes(alias)) {
dupes.push(alias);
}
}
}
for (let j = i + 1; j < list.length; j++) {
const [,,, others] = list[j];
for (let a = 1; a < aliases.length; a++) {
const alias = aliases[a];
if (!dupes.includes(alias) && others.includes(alias)) {
dupes.push(alias);
}
}

Comment on lines +243 to +248
return list.map(([lookupIndex, name, params, aliases]) => [
lookupIndex,
name,
params,
aliases.slice(1).filter((a) => !dupes.includes(a))
]);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Less memory consuming by mutate array items:

Suggested change
return list.map(([lookupIndex, name, params, aliases]) => [
lookupIndex,
name,
params,
aliases.slice(1).filter((a) => !dupes.includes(a))
]);
return list.map((item) => {
item[3] = item[3].slice(1).filter((a) => !dupes.includes(a))
return item
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale WIP Work in Progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants