Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions pkg/slices/slices.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,8 @@ func Clone[S ~[]E, E any](s S) S {

// Delete removes the element i from s, returning the modified slice.
func Delete[S ~[]E, E any](s S, i int) S {
// "If those elements contain pointers you might consider zeroing those elements
// so that objects they reference can be garbage collected."
var empty E
s[i] = empty
// Since Go 1.22, "slices.Delete zeroes the elements s[len(s)-(j-i):len(s)]"
// (no memory leak)
return slices.Delete(s, i, i+1)
}

Expand Down