Closed earthboundkid closed 1 year ago
CC @ianlancetaylor, @eliben.
Can you link to a couple of places? Thanks.
I'm fine with adding DeleteFunc
but I don't see how it makes sense to remove Delete
. The function's doc comment is even careful to explain its performance.
I'm just going to do cursory reviews of the first handful of examples:
slices.Delete(o.tenantIDToForwarders["testTenantID"], idx, idx)
Around a quarter of examples seem to be misuses, and many examples are some variant of i := slices.Index(s, something); if i != -1 { s = slices.Delete(s, i, i+1) }.
Closing as duplicate of #54768.
Problem:
A quick search for
slices.Delete
on SourceGraph shows that many calls toslices.Delete
are preceded by a call toslices.Index
. This is often done in a loop, leading to needlessly terrible performance.Possible solutions:
Delete
from the standard library slices package.