Use string.Contains(char) wherever possible - fallback to IndexOf if possible#49094
Use string.Contains(char) wherever possible - fallback to IndexOf if possible#49094MeikTranel wants to merge 1 commit intodotnet:mainfrom
Conversation
…the overload isnt available string.Contains(char) offers better performance since by design it only needs a single iteration loop. In preparation for consuming a new analyzer we want this to be fixed in the runtime beforehand. Discussion: dotnet#47180
|
I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label. |
|
Thank you for the PR. These changes aren't worth the complication it adds (we don't want to churn the speech code base, and neither of these call sites are perf sensitive). I think we should not make these changes. |
|
I can't say much about the performance sensitivity of System.Speech but i would generally agree. The NetframeworkUtils change would only surface if someone were to use |
|
Thanks. We can revisit when we import the new rule into the repo (thank you for working on it). We may want to enable it as a warning for the whole repo but suppress it for projects like these; we do that with a few other such rules. |
Fix remaining violations of the discussed
string.Contains(string)->string.Contains(char)rule.Discussion
#47180
Additional context
#24068
dotnet/coreclr#15740
#36310