KEMBAR78
Analyzer: Report inefficient use of sets. · Issue #85490 · dotnet/runtime · GitHub
Skip to content

Analyzer: Report inefficient use of sets. #85490

@geeknoid

Description

@geeknoid

Similar to #33799, use of sets can be optimized. Redundant uses of Contains can be removed around use of .Add and .Remove methods.

if (!set.Contains("Foo")) set.Add("Foo");
if (set.Contains("Foo")) set.Remove("Foo");

No need for the calls to Contains in the above.

Suggested category: Performance
Suggested severity: Info

Metadata

Metadata

Assignees

Labels

api-approvedAPI was approved in API review, it can be implementedarea-System.Collectionscode-analyzerMarks an issue that suggests a Roslyn analyzercode-fixerMarks an issue that suggests a Roslyn code fixerpartner-impactThis issue impacts a partner who needs to be kept updated

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions