- Notifications
You must be signed in to change notification settings - Fork5.2k
Labels
Milestone
Description
#68328 is adding a new caching mechanism for IndexOfAny, such that instead of:
privatestaticreadonlychar[]s_values=new[]{ ...}...intindex=span.IndexOfAny(s_values);
you can write:
privatestaticreadonlyIndexOfAnyValues<char>s_values=IndexOfAnyValues.Create(new[]{ ...}); ...intindex=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.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.