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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core-js-compat] Filter available modules without using an intermediate set #590

Merged

Conversation

nicolo-ribaudo
Copy link
Contributor

@nicolo-ribaudo nicolo-ribaudo commented Jul 4, 2019

"semver": "^6.1.3"
},
"devDependencies": {
"core-js-pure": "3.1.4",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is still used by packages/core-js-compat/src/build-entries.js (which isn't included in the published package, so it can be a dev dependency).

Copy link
Owner

Choose a reason for hiding this comment

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

Since it's a similar case like in index, it would be better also replace it.

@@ -19,7 +18,7 @@ function getModulesForEntryPoint(entry) {
const relative = resolve(dir, dependency);
result.push(...getModulesForEntryPoint(relative));
}
return [...intersection(new Set(result), order)];
return result.sort((a, b) => order.indexOf(a) > order.indexOf(b) ? 1 : -1);
Copy link
Owner

Choose a reason for hiding this comment

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

It's slow -/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh I tought that you meant to remove intersection like this. Would it be ok to leave it there as it was before?

Copy link
Owner

Choose a reason for hiding this comment

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

Something like

const resultSet = new Set(result);
return order.filter(it => resultSet.has(it));

could be better.

Copy link
Owner

@zloirock zloirock Jul 4, 2019

Choose a reason for hiding this comment

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

O(n) vs O(n^2*log n) if I understood correctly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah good idea.

@zloirock zloirock merged commit f8ad1c6 into zloirock:master Jul 4, 2019
@nicolo-ribaudo nicolo-ribaudo deleted the compat-remove-set-intersection branch July 4, 2019 22:46
@nicolo-ribaudo
Copy link
Contributor Author

Thanks!

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

Successfully merging this pull request may close these issues.

2 participants