This commit is contained in:
Samuel Berthe
2026-03-06 00:45:55 +01:00
parent b11e461ff4
commit 0d0ceb74f1
-33
View File
@@ -1,33 +0,0 @@
# Performance Optimizations Report
## PR #827 - Reject / RejectErr / RejectMap
- Preallocate result slice with `make(Slice, 0, len(collection))` instead of `Slice{}`
- Avoids repeated grow-and-copy reallocations as elements are appended
## PR #829 - UniqMap
- Collect results directly during the single map-building pass instead of calling `Keys(seen)` afterward
- Eliminates a second full iteration over the map to extract keys
- Eliminates a separate slice allocation inside `Keys()`
- Preserves insertion order (old code returned non-deterministic map iteration order)
## PR #830 - Difference
- Preallocate result slices with `make(Slice, 0, len(listN))` instead of `Slice{}`
- Avoids repeated grow-and-copy reallocations as elements are appended
## PR #831 - FromSlicePtr / FromSlicePtrOr
- Replace indirect `Map()` call with closure by a direct loop
- Eliminates per-element function call overhead from the closure indirection
## PR #833 - CountValues, UniqKeys, UniqValues, FilterKeys, FilterValues, FilterKeysErr, FilterValuesErr
- Add size hint to map allocation in CountValues: `make(map[T]int)` → `make(map[T]int, len(collection))`
- Avoids repeated map rehashing as entries are added
- Add capacity hint to result slice in UniqKeys/UniqValues: `make([]K, 0)` → `make([]K, 0, size)`
- Avoids repeated slice grow-and-copy reallocations
- Add capacity hint to result slice in FilterKeys/FilterValues/FilterKeysErr/FilterValuesErr: `make([]K, 0)` → `make([]K, 0, len(in))`
- Avoids repeated slice grow-and-copy reallocations
## PR #??? - RepeatBy / Fill / Repeat
- Replace `make([]T, 0, count)` + `append(result, ...)` with `make([]T, count)` + `result[i] = ...`
- Eliminates per-element append overhead (bounds check, length increment, slice header update)
- Size is known upfront so direct index assignment is safe and faster
- RepeatByErr left unchanged: early error return makes direct index problematic (would allocate full slice then discard)