⚡ Bolt: Replace path().is_file() with file_type().is_some_and(|ft| ft.is_file())#583
Conversation
….is_file()) When traversing directories using crates like `ignore`, the metadata (including file type) is retrieved efficiently during the `readdir` operation. Calling `entry.path().is_file()` results in an unnecessary `stat` system call to check if it's a file, drastically slowing down recursive directory scans. By replacing `.path().is_file()` with `.file_type().is_some_and(|ft| ft.is_file())` in all the workspace `WalkBuilder` instances, we utilize the already cached metadata, significantly improving performance when discovering source files across large directories. Co-authored-by: mudcube <101564+mudcube@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
Deploying typemill with
|
| Latest commit: |
192ac45
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://dc526a99.typemill.pages.dev |
| Branch Preview URL: | https://bolt-optimize-stat-calls-dir.typemill.pages.dev |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 192ac45083
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let path = entry.path(); | ||
| if path.is_file() { | ||
| // ⚡ Bolt: Use entry.file_type() to avoid unnecessary stat syscalls | ||
| if entry.file_type().is_some_and(|ft| ft.is_file()) { |
There was a problem hiding this comment.
Preserve symlinked files during scans
When the workspace contains a symlink to a source file, this changes behavior: Path::is_file() follows the symlink and previously included it, while DirEntry::file_type() reports the directory entry itself and returns a symlink file type when WalkBuilder is not configured with follow_links(true). As a result, symlinked project files are now skipped by import scanning, so imports in those files will not be updated; the same replacement appears in the other changed walkers as well. Consider using entry.file_type().is_some_and(|ft| ft.is_file()) || entry.path().is_file() (or explicitly following links) if symlinked files should remain supported.
Useful? React with 👍 / 👎.
💡 What: Replacing
.path().is_file()with.file_type().is_some_and(|ft| ft.is_file())when traversing directories usingignoreorwalkdir.🎯 Why: Avoids unnecessary
statsyscalls during directory traversal because metadata is already retrieved duringreaddir.📊 Impact: Faster directory walking when filtering files.
🔬 Measurement: Observe faster performance during workspace operations involving bulk file discovery.
PR created automatically by Jules for task 9603200225256109730 started by @mudcube