Commit graph

2 commits

Author SHA1 Message Date
07d05425bb
perf: improve GroupBy map initialization
Fixes useless capacity hint of 0 for map initialization.
Uses estimated capacity of len(values)/10 to reduce map
resizing operations.

Changes:
- Before: make(map[K][]V, 0) - capacity 0 is meaningless for maps
- After: make(map[K][]V, len(values)/10) - reasonable estimate

Impact:
- Reduces map resizing overhead during population
- Assumes ~10% unique keys (reasonable for grouping operations)
- May over-allocate for high cardinality, but acceptable trade-off

This is a minor optimization that avoids repeated map growth
when keys are added.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-14 14:32:05 +01:00
Ruidy
e5b3ad8ef1
add groupBy function (#28) 2022-04-20 22:23:59 +02:00