dotnet/runtime
View on GitHubPrefer Dictionary.Remove(key, out value) over Dictionary.this[key], followed by Dictionary.Remove(key)
Open
#33,800 opened on Mar 19, 2020
api-approvedarea-System.Collectionscode-analyzercode-fixerenhancementhelp wanted
Repository metrics
- Stars
- (17,886 stars)
- PR merge metrics
- (Avg merge 12d 11h) (661 merged PRs in 30d)
Description
Dictionary.ContainsKey<K, V(key), followed by Dictionary<K, V.this[key], followed by Dictionary<K, V>.Remove(key) can be combined into a single Remove call, using the overload accepting out TValue value.
Category: Performance