Skip to content

Commit ff8bbb9

Browse files
authored
Avoid double Dictionary lookups (incl. hashkey generation) by using new Dictionary methods (#120456)
1 parent f981e2a commit ff8bbb9

File tree

2 files changed

+2
-7
lines changed

2 files changed

+2
-7
lines changed

src/coreclr/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,10 +1177,8 @@ private void PopulateEvents(
11771177
{
11781178
string name = eventInfo.Name;
11791179

1180-
if (csEventInfos.ContainsKey(name))
1180+
if (!csEventInfos.TryAdd(name, eventInfo))
11811181
continue;
1182-
1183-
csEventInfos[name] = eventInfo;
11841182
}
11851183
else
11861184
{

src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/Compiler.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,7 @@ public Stylesheet CreateStylesheet()
9696

9797
public void AddModule(string baseUri)
9898
{
99-
if (!_moduleOrder.ContainsKey(baseUri))
100-
{
101-
_moduleOrder[baseUri] = _moduleOrder.Count;
102-
}
99+
_moduleOrder.TryAdd(baseUri, _moduleOrder.Count);
103100
}
104101

105102
public void ApplyNsAliases(ref string? prefix, ref string nsUri)

0 commit comments

Comments
 (0)