Skip to content

perf: avoid redundant Abs and Stat on directory walks#54

Open
leno23 wants to merge 1 commit into
dolph:mainfrom
leno23:perf/direntry-and-abs-path-issue-13-15
Open

perf: avoid redundant Abs and Stat on directory walks#54
leno23 wants to merge 1 commit into
dolph:mainfrom
leno23:perf/direntry-and-abs-path-issue-13-15

Conversation

@leno23
Copy link
Copy Markdown

@leno23 leno23 commented May 17, 2026

Summary

Test plan

  • go test ./...

Closes #13 and #15

Made with Cursor

Use NewChildFile to join paths under an absolute parent without
calling filepath.Abs per entry. Use DirEntry.IsDir for type checks so
directory entries do not trigger an extra os.Stat.

Closes dolph#13 and dolph#15

Co-authored-by: Cursor <cursoragent@cursor.com>
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread file_handling.go
func NewChildFile(parent *File, name string, entry os.DirEntry) *File {
child := &File{Path: filepath.Join(parent.Path, name)}
if entry != nil {
isDir := entry.IsDir()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Redundant os.Stat call per directory entry duplicates information already in DirEntry

1 participant