Reduce allocations in Composer, NuGet, Go and Python parsers - #96
Merged
Merged
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The reviewed changes preserve behavior and have no unresolved blocking issues.
Pull request overview
Reduces allocations in Composer, NuGet, Go, and Python parsers while preserving parsing behavior.
Changes:
- Preallocates Composer and NuGet dependency slices.
- Uses
strings.SplitSeqfor line-based parsers. - Adds regression tests and allocation benchmarks.
File summaries
| File | Description |
|---|---|
lock_capacity_test.go |
Adds capacity tests and benchmarks. |
line_iteration_test.go |
Adds line-ending tests and benchmarks. |
internal/pypi/pypi.go |
Uses iterator-based line parsing. |
internal/nuget/nuget.go |
Preallocates dependencies and uses SplitSeq. |
internal/golang/golang.go |
Uses iterator-based line parsing. |
internal/composer/composer.go |
Preallocates Composer dependencies. |
Review details
- Files reviewed: 6/6 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.
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.
Preallocate dependency slices in Composer and NuGet lockfile parsers, and use
strings.SplitSeqin Go, Python and Paket parsers to avoid allocating a slice of every line. Preserve empty results, package filtering and deduplication across target frameworks.Public
Parsebenchmarks show 26% fewer allocated bytes for the Composer fixture and 5–43% fewer for NuGet fixtures. Synthetic lockfiles with 10,000 dependencies use 43–63% fewer bytes. Line iteration saves another 0.6–1.4% in the six affected line-based formats.