Skip to content

Use Dictionary<T, M>.TryAdd() where possible - #11767

Merged
Dongbo Wang (daxian-dbw) merged 1 commit into
PowerShell:masterfrom
iSazonov:cleanup-use-tryadd
Feb 6, 2020
Merged

Dongbo Wang (daxian-dbw) merged 1 commit into
PowerShell:masterfrom
iSazonov:cleanup-use-tryadd

Conversation

@iSazonov

@iSazonov Ilya (iSazonov) commented Feb 4, 2020 •

Copy link
Copy Markdown
Collaborator

PR Summary

Replace follow patterns:

if (!patterns.ContainsKey(name))
{
    patterns.Add(name, value);
}

with new Dictionary<T, M>.TryAdd() method:

patterns.TryAdd(name, value);

PR Context

PR Checklist

@iSazonov Ilya (iSazonov) added the CL-CodeCleanup Indicates that a PR should be marked as a Code Cleanup change in the Change Log label Feb 4, 2020
@iSazonov Ilya (iSazonov) added this to the 7.1.0-preview.1 milestone Feb 4, 2020
@daxian-dbw
Dongbo Wang (daxian-dbw) merged commit 60387f1 into PowerShell:master Feb 6, 2020
@iSazonov
Ilya (iSazonov) deleted the cleanup-use-tryadd branch February 7, 2020 02:56
@ghost

Copy link
Copy Markdown

🎉v7.1.0-preview.1 has been released which incorporates this pull request.:tada:

Handy links:

Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-CodeCleanup Indicates that a PR should be marked as a Code Cleanup change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants