-
Notifications
You must be signed in to change notification settings - Fork 18k
slices: low performance from common misuse of Delete #58818
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
CC @ianlancetaylor, @eliben. |
Can you link to a couple of places? Thanks. I'm fine with adding |
I'm just going to do cursory reviews of the first handful of examples:
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.The text was updated successfully, but these errors were encountered: