Optimize include extraction hot path in findIncludesInContent#35004
Conversation
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
findIncludesInContent
There was a problem hiding this comment.
Pull request overview
This PR targets a benchmark regression by removing the extra full-content pre-scan in findIncludesInContent, so include extraction is performed via a single line-by-line pass while keeping parseIncludePath semantics intact.
Changes:
- Removed
hasDirectiveMarkerand the early-return “no directives” fast path fromfindIncludesInContent. - Kept the existing manual line scan and
parseIncludePathlogic for directive parsing.
Show a summary per file
| File | Description |
|---|---|
pkg/cli/remove_command.go |
Removes the directive-marker pre-scan helper and always performs the existing line-based include extraction pass. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 1/1 changed files
- Comments generated: 1
| return []string{}, nil | ||
| } | ||
|
|
||
| var includes []string |
|
@copilot review all comments |
|
\n\n@copilot please confirm the benchmark improvement and add a brief note addressing the existing review comment.
|
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Addressed. I reviewed the feedback and pushed |
BenchmarkFindIncludesInContentregressed by ~45.8% versus the historical run, pointing to extra work in include-detection. This change tightens the scan path by removing redundant traversal while preserving include parsing behavior.Regression focus
findIncludesInContent) was doing an additional full-content pre-scan before line parsing.Code changes
hasDirectiveMarkerand its call site fromfindIncludesInContent.parseIncludePath) unchanged, so directive semantics remain intact.Behavioral impact
pr-sous-chef: branch update attempted in https://github.com/github/gh-aw/actions/runs/26470389940