Reduce matching allocations and skip unrelated ignore rules - #30
Merged
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
No unresolved blocking issues were identified.
Pull request overview
Optimizes gitignore matching and directory traversal while preserving the public API.
Changes:
- Groups scoped rules and skips unrelated scopes.
- Reduces matching allocations and reuses parent checks.
- Adds benchmarks, conformance coverage, concurrency tests, and documentation.
File summaries
| File | Description |
|---|---|
| README.md | Documents matching semantics and benchmark methodology. |
| performance_test.go | Adds performance, concurrency, and traversal tests. |
| gitignore.go | Implements grouped matching and traversal optimizations. |
| gitignore_bench_test.go | Adds literal-match benchmarks. |
| conformance_test.go | Adds nested-walk conformance coverage. |
Review details
- Files reviewed: 5/5 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
andrew
force-pushed
the
perf-literal-suffix
branch
from
September 13, 2026 00:37
78300c9 to
4e5369e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Common path matches now avoid heap allocation, rules from unrelated directory scopes are skipped as groups, and directory walks reuse parent checks and discard rules after leaving a subtree. Basename patterns also avoid scanning earlier path components. The public API is unchanged.
Local benchmarks show zero allocations for common matches, about 27% fewer allocated bytes when loading 1,000 scoped rules, and about 14% fewer allocated bytes for a wide directory walk. Timing results remain noisy, with some runs reporting regressions, so these figures describe allocation reductions only.
Adds benchmarks for construction, path depth, rule ordering, sibling scopes, wildcard shapes, parallel matching, and traversal, plus Git conformance coverage for nested walks and tests for deep paths, concurrent matching, and interleaved scopes. Documents how to collect benchmark samples and clarifies parent-directory exclusion.