Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Analyzer] Use IndexOfAnyValues instead of inlined or cached array #78587

Closed
dotnet/roslyn-analyzers
#6898
Assignees
MihaZupan
Labels
api-approvedAPI was approved in API review, it can be implementedarea-System.Memorycode-analyzerMarks an issue that suggests a Roslyn analyzercode-fixerMarks an issue that suggests a Roslyn code fixertenet-performancePerformance related issue
Milestone
@stephentoub

Description

@stephentoub

#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.

Metadata

Metadata

Assignees

Labels

api-approvedAPI was approved in API review, it can be implementedarea-System.Memorycode-analyzerMarks an issue that suggests a Roslyn analyzercode-fixerMarks an issue that suggests a Roslyn code fixertenet-performancePerformance related issue

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp