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

Reduce micromatch overhead in jest-haste-map HasteFS #10132

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

### Performance

- `[jest-haste-map]` Reduce micromatch overhead in jest-haste-map HasteFS

## 26.0.1

### Fixes
Expand Down
5 changes: 4 additions & 1 deletion packages/jest-haste-map/src/HasteFS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,12 @@ export default class HasteFS {
root: Config.Path | null,
): Set<Config.Path> {
const files = new Set<string>();

const matchers = globs.map(glob => micromatch.matcher(glob));

for (const file of this.getAbsoluteFileIterator()) {
const filePath = root ? fastPath.relative(root, file) : file;
if (micromatch([replacePathSepForGlob(filePath)], globs).length > 0) {
if (matchers.some(isMatch => isMatch(replacePathSepForGlob(filePath)))) {
files.add(file);
}
}
Expand Down