mailgun / holster

A place to keep useful golang functions and small libraries
Apache License 2.0
289 stars 35 forks source link

slice.Remove #185

Closed MatthewEdge closed 11 months ago

MatthewEdge commented 11 months ago

This function does fall within the warning about potential memory leaks if the slices modified are long-lived. See slices.Delete() docs for more info

Implementation Notes

Benchmarking Checks

On an Intel Mac, to gut check the no-allocation claim:

goos: darwin
goarch: amd64
pkg: github.com/mailgun/holster/v4/slice
cpu: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
BenchmarkRemove-12          242117806            4.944 ns/op           0 B/op          0 allocs/op
BenchmarkRemove-12          223956164            4.946 ns/op           0 B/op          0 allocs/op
BenchmarkRemove-12          244528929            4.919 ns/op           0 B/op          0 allocs/op
BenchmarkRemove-12          244414112            4.878 ns/op           0 B/op          0 allocs/op
BenchmarkRemove-12          244394427            5.028 ns/op           0 B/op          0 allocs/op
BenchmarkRemove-12          229395693            4.942 ns/op           0 B/op          0 allocs/op
BenchmarkRemove-12          243575570            4.853 ns/op           0 B/op          0 allocs/op
BenchmarkRemove-12          244754611            5.171 ns/op           0 B/op          0 allocs/op
BenchmarkRemove-12          234260016            5.056 ns/op           0 B/op          0 allocs/op
BenchmarkRemove-12          246132768            4.855 ns/op           0 B/op          0 allocs/op