Skip to content

♻️ chore: Use make() to preallocate relevantExtractors in Session Middleware - #4562

Open
SivaPA08 wants to merge 1 commit into
gofiber:mainfrom
SivaPA08:main
Open

♻️ chore: Use make() to preallocate relevantExtractors in Session Middleware#4562
SivaPA08 wants to merge 1 commit into
gofiber:mainfrom
SivaPA08:main

Conversation

@SivaPA08

Copy link
Copy Markdown
Contributor

Preallocate relevantExtractors using make() to reduce unnecessary slice reallocations.

@SivaPA08
SivaPA08 requested a review from a team as a code owner July 28, 2026 12:40
@welcome

welcome Bot commented Jul 28, 2026

Copy link
Copy Markdown

Thanks for opening this pull request! 🎉 Please check out our contributing guidelines. If you need help or want to chat with us, join us on Discord https://gofiber.io/discord

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

The session middleware preallocates the filtered extractor slice using the extractor chain length, reducing potential reallocations during appends.

Changes

Session extractor optimization

Layer / File(s) Summary
Preallocate relevant extractors
middleware/session/session.go
Initializes relevantExtractors with capacity for the extractor chain before filtering.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Suggested reviewers: efectn

Poem

A rabbit hops through slices bright,
Reserving room before the write.
Fewer moves beneath the moon,
Extractors gather in tune.
“Preallocate!” I cheer—“well done!”

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is too brief and omits the required template sections like Fixes #, changes, type of change, checklist, and commit formatting. Expand it to the repository template by adding the issue reference, change summary, type of change, checklist items, and any relevant benchmarks/tests.
✅ Passed checks (4 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly names the slice preallocation change in session middleware and matches the main PR objective.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Jul 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.25%. Comparing base (48b5ea3) to head (2a8e240).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4562      +/-   ##
==========================================
- Coverage   93.29%   93.25%   -0.05%     
==========================================
  Files         140      140              
  Lines       14854    14854              
==========================================
- Hits        13858    13852       -6     
- Misses        620      625       +5     
- Partials      376      377       +1     
Flag Coverage Δ
unittests 93.25% <100.00%> (-0.05%) ⬇️

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.

@gaby gaby changed the title ♻️ Refactor: Use make() to preallocate relevantExtractors ♻️ chore: Use make() to preallocate relevantExtractors Jul 28, 2026
@gaby gaby changed the title ♻️ chore: Use make() to preallocate relevantExtractors ♻️ chore: Use make() to preallocate relevantExtractors in Session Middleware Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants