Skip to content

Commit

Permalink
Revert changes for static delegate
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-strecker-sonarsource committed Oct 17, 2023
1 parent b5fd4b5 commit 3386603
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions StyleCop.Analyzers/StyleCop.Analyzers/Lightup/LightupHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,7 @@ internal static bool CanWrapObject(object obj, Type underlyingType)
return false;
}

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

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

// Avoid creating the delegate if the value already exists
if (!SupportedSyntaxWrappers.TryGetValue(underlyingType, out var wrappedSyntax))
{
wrappedSyntax = SupportedSyntaxWrappers.GetOrAdd(underlyingType, static _ => new ConcurrentDictionary<SyntaxKind, bool>());
}
ConcurrentDictionary<SyntaxKind, bool> wrappedSyntax = SupportedSyntaxWrappers.GetOrAdd(underlyingType, static _ => new ConcurrentDictionary<SyntaxKind, bool>());

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

// Avoid creating the delegate if the value already exists
if (!SupportedOperationWrappers.TryGetValue(underlyingType, out var wrappedSyntax))
{
wrappedSyntax = SupportedOperationWrappers.GetOrAdd(underlyingType, static _ => new ConcurrentDictionary<OperationKind, bool>());
}
ConcurrentDictionary<OperationKind, bool> wrappedSyntax = SupportedOperationWrappers.GetOrAdd(underlyingType, static _ => new ConcurrentDictionary<OperationKind, bool>());

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

0 comments on commit 3386603

Please sign in to comment.