perf: avoid redundant Abs and Stat on directory walks#54
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5fa3384b8b
ℹ️ 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".
| func NewChildFile(parent *File, name string, entry os.DirEntry) *File { | ||
| child := &File{Path: filepath.Join(parent.Path, name)} | ||
| if entry != nil { | ||
| isDir := entry.IsDir() |
There was a problem hiding this comment.
Preserve symlinked-directory recursion behavior
Using DirEntry.IsDir() here changes directory detection from os.Stat(...).IsDir() to lstat-style type checks, so a symlink that points to a directory is now treated as a non-directory. In HandleFile, those entries will skip WalkDir and be processed like files, which means replacements inside symlinked directories are no longer traversed. This is a behavioral regression introduced by this commit for repositories that rely on directory symlinks.
Useful? React with 👍 / 👎.
Summary
NewChildFileto join paths under an absolute parent without callingfilepath.Absper entry (filepath.Abs is called for every File, including children of an already-absolute path #15).DirEntry.IsDirfor directory detection so walks do notos.Statevery directory entry (Redundant os.Stat call per directory entry duplicates information already in DirEntry #13).Test plan
go test ./...Closes #13 and #15
Made with Cursor