Skip to content

Commit 3386603

Browse files
Revert changes for static delegate
1 parent b5fd4b5 commit 3386603

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

StyleCop.Analyzers/StyleCop.Analyzers/Lightup/LightupHelpers.cs

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,7 @@ internal static bool CanWrapObject(object obj, Type underlyingType)
6565
return false;
6666
}
6767

68-
// Avoid creating the delegate if the value already exists
69-
if (!SupportedObjectWrappers.TryGetValue(underlyingType, out var wrappedObject))
70-
{
71-
wrappedObject = SupportedObjectWrappers.GetOrAdd(underlyingType, static _ => new ConcurrentDictionary<Type, bool>());
72-
}
68+
ConcurrentDictionary<Type, bool> wrappedObject = SupportedObjectWrappers.GetOrAdd(underlyingType, static _ => new ConcurrentDictionary<Type, bool>());
7369

7470
// Avoid creating the delegate and capture class
7571
if (!wrappedObject.TryGetValue(obj.GetType(), out var canCast))
@@ -95,11 +91,7 @@ internal static bool CanWrapNode(SyntaxNode node, Type underlyingType)
9591
return false;
9692
}
9793

98-
// Avoid creating the delegate if the value already exists
99-
if (!SupportedSyntaxWrappers.TryGetValue(underlyingType, out var wrappedSyntax))
100-
{
101-
wrappedSyntax = SupportedSyntaxWrappers.GetOrAdd(underlyingType, static _ => new ConcurrentDictionary<SyntaxKind, bool>());
102-
}
94+
ConcurrentDictionary<SyntaxKind, bool> wrappedSyntax = SupportedSyntaxWrappers.GetOrAdd(underlyingType, static _ => new ConcurrentDictionary<SyntaxKind, bool>());
10395

10496
// Avoid creating the delegate and capture class
10597
if (!wrappedSyntax.TryGetValue(node.Kind(), out var canCast))
@@ -125,11 +117,7 @@ internal static bool CanWrapOperation(IOperation operation, Type underlyingType)
125117
return false;
126118
}
127119

128-
// Avoid creating the delegate if the value already exists
129-
if (!SupportedOperationWrappers.TryGetValue(underlyingType, out var wrappedSyntax))
130-
{
131-
wrappedSyntax = SupportedOperationWrappers.GetOrAdd(underlyingType, static _ => new ConcurrentDictionary<OperationKind, bool>());
132-
}
120+
ConcurrentDictionary<OperationKind, bool> wrappedSyntax = SupportedOperationWrappers.GetOrAdd(underlyingType, static _ => new ConcurrentDictionary<OperationKind, bool>());
133121

134122
// Avoid creating the delegate and capture class
135123
if (!wrappedSyntax.TryGetValue(operation.Kind, out var canCast))

0 commit comments

Comments
 (0)