dotnet/runtime

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

Open

#33.800 aberto em 19 de mar. de 2020

Ver no GitHub
 (7 comments) (0 reactions) (0 assignees)C# (5.445 forks)batch import
api-approvedarea-System.Collectionscode-analyzercode-fixerenhancementhelp wanted

Métricas do repositório

Stars
 (17.886 stars)
Métricas de merge de PR
 (Mesclagem média 12d 11h) (661 fundiu PRs em 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

Guia do colaborador