Closed MatthewEdge closed 11 months ago
slice.Remove
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
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
slice.Remove
as a safer variant of the slices.Delete() function that avoids the panic case for invalid indeciesThis 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: