perf: reduce allocations in NewV3 and NewV5#221
Conversation
anatoly-kussul
commented
Jul 9, 2025
There was a problem hiding this comment.
Pull Request Overview
This PR optimizes the allocation performance of UUID generation methods NewV3 and NewV5 by eliminating all heap allocations. The changes inline the hash computation logic and use a pre-allocated buffer to avoid unnecessary memory allocations.
- Removes the generic
newFromHashhelper function and inlines hash computation directly in NewV3 and NewV5 - Pre-allocates hash result buffer with
make([]byte, 0, capacity)to avoid allocations inh.Sum(nil) - Uses named return values to leverage zero-value initialization
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #221 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 5 5
Lines 516 517 +1
=========================================
+ Hits 516 517 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
@anatoly-kussul thank you very much for this contribution, and apologies it took me a while to get to it. Nice change! Simple but impactful perf improvements are appreciated. |