Skip to content

Reduce allocations in MakePURLString - #26

Merged
andrew merged 2 commits into
mainfrom
perf/reduce-make-purl-allocations
Aug 14, 2026
Merged

Reduce allocations in MakePURLString#26
andrew merged 2 commits into
mainfrom
perf/reduce-make-purl-allocations

Conversation

@andrew

@andrew andrew commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Route MakePURLString through the direct package URL encoder and pre-size output buffers using escaped lengths. This avoids intermediate PURL allocations while preserving canonical component escaping across ecosystems.

Add benchmarks covering package and version PURL construction for npm, scoped npm, and Go, plus compatibility cases for ecosystem-specific splitting and escaping.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR optimizes PURL string construction by routing MakePURLString/BuildPURLString through a direct encoder path and pre-sizing the output buffer based on escaped component lengths, reducing intermediate allocations while preserving canonical escaping behavior across ecosystems.

Changes:

  • Introduces a shared buildPURLString fast-path encoder with capacity pre-sizing based on escaped lengths.
  • Refactors ecosystem string handling toward shared constants and updates MakePURLString to use the direct encoder.
  • Adds expanded MakePURLString compatibility tests and new benchmarks covering package/version PURL construction for npm (including scoped), and Go.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
makepurl.go Adds direct PURL string builder + escaped-length estimators and updates namespace encoding loop.
ecosystem.go Centralizes ecosystem constants and routes MakePURLString through the new builder.
ecosystem_test.go Expands MakePURLString tests to cover escaping and ecosystem-specific behavior with canonical cross-checks.
ecosystem_bench_test.go Adds benchmarks for MakePURLString across representative ecosystems/packages.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread makepurl.go
@andrew
andrew merged commit 8eaebb1 into main Aug 14, 2026
5 checks passed
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.

2 participants