dotnet/runtime

Prefer Dictionary.Remove(key, out value) over Dictionary.this[key], followed by Dictionary.Remove(key)

Open

#33.800 aperta il 19 mar 2020

Vedi su GitHub
 (7 commenti) (0 reazioni) (0 assegnatari)C# (5445 fork)batch import
api-approvedarea-System.Collectionscode-analyzercode-fixerenhancementhelp wanted

Metriche repository

Star
 (17.886 star)
Metriche merge PR
 (Merge medio 12g 11h) (661 PR mergiate in 30 g)

Descrizione

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

Guida contributor