Browse Source

Analyzer: simplify concurrency handling

pull/170/head
Ed Harvey 14 years ago
parent
commit
0ccbbb2e1e
  1. 15
      ILSpy/TreeNodes/Analyzer/AnalyzedMethodUsedByTreeNode.cs

15
ILSpy/TreeNodes/Analyzer/AnalyzedMethodUsedByTreeNode.cs

@ -17,7 +17,7 @@
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System; using System;
using System.Collections; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading; using System.Threading;
using ICSharpCode.TreeView; using ICSharpCode.TreeView;
@ -30,7 +30,7 @@ namespace ICSharpCode.ILSpy.TreeNodes.Analyzer
{ {
private readonly MethodDefinition analyzedMethod; private readonly MethodDefinition analyzedMethod;
private readonly ThreadingSupport threading; private readonly ThreadingSupport threading;
private Hashtable foundMethods; private ConcurrentDictionary<MethodDefinition, int> foundMethods;
private object hashLock = new object(); private object hashLock = new object();
public AnalyzedMethodUsedByTreeNode(MethodDefinition analyzedMethod) public AnalyzedMethodUsedByTreeNode(MethodDefinition analyzedMethod)
@ -69,7 +69,7 @@ namespace ICSharpCode.ILSpy.TreeNodes.Analyzer
private IEnumerable<SharpTreeNode> FetchChildren(CancellationToken ct) private IEnumerable<SharpTreeNode> FetchChildren(CancellationToken ct)
{ {
foundMethods = new Hashtable(); foundMethods = new ConcurrentDictionary<MethodDefinition, int>();
var analyzer = new ScopedWhereUsedAnalyzer<SharpTreeNode>(analyzedMethod, FindReferencesInType); var analyzer = new ScopedWhereUsedAnalyzer<SharpTreeNode>(analyzedMethod, FindReferencesInType);
foreach (var child in analyzer.PerformAnalysis(ct)) { foreach (var child in analyzer.PerformAnalysis(ct)) {
@ -109,14 +109,7 @@ namespace ICSharpCode.ILSpy.TreeNodes.Analyzer
private bool HasAlreadyBeenFound(MethodDefinition method) private bool HasAlreadyBeenFound(MethodDefinition method)
{ {
lock (hashLock) { return !foundMethods.TryAdd(method, 0);
if (foundMethods.Contains(method)) {
return true;
} else {
foundMethods.Add(method, null);
return false;
}
}
} }
} }
} }

Loading…
Cancel
Save