-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
[Analyzer] Use IndexOfAnyValues instead of inlined or cached array #78587
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
cc: @MihaZupan, @marklio |
Tagging subscribers to this area: @dotnet/area-system-memory Issue Details#68328 is adding a new caching mechanism for IndexOfAny, such that instead of: private static readonly char[] s_values = new[] { ... }
...
int index = span.IndexOfAny(s_values); you can write: private static readonly IndexOfAnyValues<char> s_values = IndexOfAnyValues.Create(new[] { ... });
...
int index = span.IndexOfAny(s_values); We should consider an info-level performance analyzer that will flag cases like that above or where IndexOfAny is being called with an inline array (e.g.
|
The analyzer looks good as proposed. Category: Performance |
Marking as 8.0 given we're backporting it in dotnet/roslyn-analyzers#6924 |
#68328 is adding a new caching mechanism for IndexOfAny, such that instead of:
you can write:
We should consider an info-level performance analyzer that will flag cases like that above or where IndexOfAny is being called with an inline array (e.g.
IndexOfAny(new[] { ... })
) (or with a string constant containing the characters), and recommend switching to use IndexOfAnyValues, ideally with a fixer to automatically make the change.The text was updated successfully, but these errors were encountered: