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

When populating ExportMap, only load file if it's not ignored #1519

Merged
merged 1 commit into from
Dec 5, 2019

Conversation

brendo
Copy link
Contributor

@brendo brendo commented Oct 28, 2019

I was debugging a project trying to understand better how the import/no-deprecated rule works. While doing this I discovered that ExportMap.for will do a I/O hit to read the path even if the path is ignored:

https://github.com/benmosher/eslint-plugin-import/blob/112a0bf442e52b25cd7029a9905df2508e191ac1/src/ExportMap.js#L313-L320

When the path is ignored, the function early exits and the content variable is not referenced, so it's essentially a wasted I/O hit.

This PR tweaks the condition to do the ignore check in one block, and check ambiguity in another.

In theory this should result in a performance boost for projects that ignore many paths as they will be skipped based off the ignore, rather than being loaded from the file system. It also cleans up the log a little bit because we know exactly why the path was ignored, because of the regex, or because it's ambiguous.

@brendo brendo force-pushed the fix_only-load-file-when-needed branch from fa64e29 to f5123cc Compare October 28, 2019 02:16
@coveralls
Copy link

coveralls commented Oct 28, 2019

Coverage Status

Coverage decreased (-0.2%) to 96.115% when pulling fb8ae71 on brendo:fix_only-load-file-when-needed into 1b96580 on benmosher:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.3%) to 96.172% when pulling fa64e29 on brendo:fix_only-load-file-when-needed into 112a0bf on benmosher:master.

5 similar comments
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.3%) to 96.172% when pulling fa64e29 on brendo:fix_only-load-file-when-needed into 112a0bf on benmosher:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.3%) to 96.172% when pulling fa64e29 on brendo:fix_only-load-file-when-needed into 112a0bf on benmosher:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.3%) to 96.172% when pulling fa64e29 on brendo:fix_only-load-file-when-needed into 112a0bf on benmosher:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.3%) to 96.172% when pulling fa64e29 on brendo:fix_only-load-file-when-needed into 112a0bf on benmosher:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.3%) to 96.172% when pulling fa64e29 on brendo:fix_only-load-file-when-needed into 112a0bf on benmosher:master.

@ljharb ljharb force-pushed the fix_only-load-file-when-needed branch from f5123cc to fb8ae71 Compare December 5, 2019 08:06
@ljharb ljharb merged commit fb8ae71 into import-js:master Dec 5, 2019
@brendo brendo deleted the fix_only-load-file-when-needed branch January 9, 2020 22:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants