Files
lo/benchmark
Samuel Berthe f7891eb41c perf: preallocate result slice in Reject, RejectErr, RejectMap (#827)
* perf(Reject): preallocate result slice capacity

Reject was using `Slice{}` (zero capacity) causing multiple
grow-and-copy allocations as elements were appended. Preallocate
with `make(Slice, 0, len(collection))` to eliminate regrowth.

benchstat (strings_1000): -42.96% time, -53.37% memory, -88.89% allocs

* perf(Reject): preallocate result slice in Reject, RejectErr, RejectMap

All three Reject variants were using zero-capacity slices (`Slice{}`
or `[]R{}`), causing multiple grow-and-copy allocations as elements
were appended. Preallocate with `make(..., 0, len(collection))` to
eliminate slice regrowth.

Reject benchstat (strings_1000): -42.96% time, -53.37% memory, -88.89% allocs
RejectErr benchstat (strings_1000): -45.11% time, -53.37% memory, -88.89% allocs
RejectMap benchstat (strings_1000): -47.63% time, -53.37% memory, -88.89% allocs
2026-03-05 18:12:24 +01:00
..