Skip to content

fix: avoid an allocation in GetQuery* when query string is empty - #4765

Open
ItalyPaleAle wants to merge 1 commit into
gin-gonic:masterfrom
ItalyPaleAle:ctx-query-allocs
Open

fix: avoid an allocation in GetQuery* when query string is empty#4765
ItalyPaleAle wants to merge 1 commit into
gin-gonic:masterfrom
ItalyPaleAle:ctx-query-allocs

Conversation

@ItalyPaleAle

Copy link
Copy Markdown
Contributor

When requesting a URL without a query string (e.g. http://example.com/), Gin was allocating a map in the heap unnecessarily, which was showing up on our benchmarks

Pull Request Checklist

Please ensure your pull request meets the following requirements:

  • Open your pull request against the master branch.
  • All tests pass in available continuous integration systems (e.g., GitHub Actions).
  • Tests are added or modified as needed to cover code changes.
  • (N/A) If the pull request introduces a new feature, the feature is documented in the docs/doc.md.

Thank you for contributing!

When requesting a URL without a query string (e.g. `http://example.com/`), Gin was allocating a map in the heap unnecessarily, which was showing up on our benchmarks
@codecov

codecov Bot commented Jul 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.33%. Comparing base (3dc1cd6) to head (b8e1de3).
⚠️ Report is 289 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4765      +/-   ##
==========================================
- Coverage   99.21%   98.33%   -0.89%     
==========================================
  Files          42       48       +6     
  Lines        3182     3176       -6     
==========================================
- Hits         3157     3123      -34     
- Misses         17       43      +26     
- Partials        8       10       +2     
Flag Coverage Δ
?
--ldflags="-checklinkname=0" -tags sonic 98.31% <100.00%> (?)
-tags go_json 98.25% <100.00%> (?)
-tags nomsgpack 98.30% <100.00%> (?)
go-1.18 ?
go-1.19 ?
go-1.20 ?
go-1.21 ?
go-1.25 98.33% <100.00%> (?)
go-1.26 98.33% <100.00%> (?)
macos-latest 98.33% <100.00%> (-0.89%) ⬇️
ubuntu-latest 98.33% <100.00%> (-0.89%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

1 participant