-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
[jest-haste-map] reduce the number of lstat calls in node crawler #9514
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
Changes from 5 commits
81c78a9
5c14c7d
819118c
4f7109a
1dd833d
6855233
f077a64
758c76a
9f0aae7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,22 +32,42 @@ function find( | |
|
|
||
| function search(directory: string): void { | ||
| activeCalls++; | ||
| fs.readdir(directory, (err, names) => { | ||
| fs.readdir(directory, {withFileTypes: true}, (err, entries) => { | ||
| activeCalls--; | ||
| if (err) { | ||
| callback(result); | ||
| return; | ||
| } | ||
| names.forEach(file => { | ||
| file = path.join(directory, file); | ||
| if (ignore(file)) { | ||
| return; | ||
| entries.forEach((entry: string | fs.Dirent) => { | ||
| let file: string; | ||
| // node < v10.10 does not support the withFileTypes option, and | ||
| // entry will be a string. | ||
| if (typeof entry === 'string') { | ||
| file = path.join(directory, entry); | ||
| } else { | ||
| file = path.join(directory, entry.name); | ||
|
|
||
| if (ignore(file)) { | ||
| return; | ||
| } | ||
|
|
||
| if (entry.isSymbolicLink()) { | ||
| return; | ||
| } | ||
|
|
||
| if (entry.isDirectory()) { | ||
| search(file); | ||
| return; | ||
| } | ||
| } | ||
SimenB marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| activeCalls++; | ||
|
|
||
| fs.lstat(file, (err, stat) => { | ||
| activeCalls--; | ||
|
|
||
| // This logic is unnecessary for node > v10.10, but leaving it in | ||
| // since we need it for backwards-compatibility still. | ||
|
Comment on lines
+69
to
+70
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @yepitschunked we're about to drop node 10 (#12220), which part of the logic does this refer to? The entire
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this PR is old, but would love your comment over in that PR 🙂 |
||
| if (!err && stat && !stat.isSymbolicLink()) { | ||
| if (stat.isDirectory()) { | ||
| search(file); | ||
|
|
@@ -58,6 +78,7 @@ function find( | |
| } | ||
| } | ||
| } | ||
|
|
||
| if (activeCalls === 0) { | ||
| callback(result); | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.