Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Strehovský <MichalStrehovsky@users.noreply.github.com>2016-04-27 23:28:09 +0300
committerMichal Strehovský <MichalStrehovsky@users.noreply.github.com>2016-04-27 23:28:09 +0300
commit1a6c068e9df96e9ba30de937ff937ae7b3696e57 (patch)
treeb62c3e5bf92eb15b3810d294a0f01559ab3f81b2 /src/ILCompiler.DependencyAnalysisFramework
parenta3a85914fb110d0bf39224a883604329ca650de3 (diff)
Implement Equals/GetHashCode for CombinedDependencyListEntry (#1202)
This was falling back to the runtime supplied implementation which has pretty bad perf characteristics. Also made the fields read only and implemented IEquatable for good measure.
Diffstat (limited to 'src/ILCompiler.DependencyAnalysisFramework')
-rw-r--r--src/ILCompiler.DependencyAnalysisFramework/src/DependencyAnalyzer.cs7
-rw-r--r--src/ILCompiler.DependencyAnalysisFramework/src/DependencyNodeCore.cs34
2 files changed, 32 insertions, 9 deletions
diff --git a/src/ILCompiler.DependencyAnalysisFramework/src/DependencyAnalyzer.cs b/src/ILCompiler.DependencyAnalysisFramework/src/DependencyAnalyzer.cs
index 024c5d546..f8af55798 100644
--- a/src/ILCompiler.DependencyAnalysisFramework/src/DependencyAnalyzer.cs
+++ b/src/ILCompiler.DependencyAnalysisFramework/src/DependencyAnalyzer.cs
@@ -162,11 +162,8 @@ namespace ILCompiler.DependencyAnalysisFramework
_conditional_dependency_store.Add(dependency.OtherReasonNode, storedDependencySet);
}
// Swap out other reason node as we're storing that as the dictionary key
- DependencyNodeCore<DependencyContextType>.CombinedDependencyListEntry conditionalDependencyStoreEntry = new DependencyNodeCore<DependencyContextType>.CombinedDependencyListEntry();
- conditionalDependencyStoreEntry.Node = dependency.Node;
- conditionalDependencyStoreEntry.Reason = dependency.Reason;
- conditionalDependencyStoreEntry.OtherReasonNode = node;
-
+ DependencyNodeCore<DependencyContextType>.CombinedDependencyListEntry conditionalDependencyStoreEntry =
+ new DependencyNodeCore<DependencyContextType>.CombinedDependencyListEntry(dependency.Node, node, dependency.Reason);
storedDependencySet.Add(conditionalDependencyStoreEntry);
}
}
diff --git a/src/ILCompiler.DependencyAnalysisFramework/src/DependencyNodeCore.cs b/src/ILCompiler.DependencyAnalysisFramework/src/DependencyNodeCore.cs
index 4535c00fc..c61b1d4cd 100644
--- a/src/ILCompiler.DependencyAnalysisFramework/src/DependencyNodeCore.cs
+++ b/src/ILCompiler.DependencyAnalysisFramework/src/DependencyNodeCore.cs
@@ -46,7 +46,7 @@ namespace ILCompiler.DependencyAnalysisFramework
}
}
- public struct CombinedDependencyListEntry
+ public struct CombinedDependencyListEntry : IEquatable<CombinedDependencyListEntry>
{
public CombinedDependencyListEntry(DependencyNodeCore<DependencyContextType> node,
DependencyNodeCore<DependencyContextType> otherReasonNode,
@@ -67,9 +67,35 @@ namespace ILCompiler.DependencyAnalysisFramework
}
// Used by HashSet, so must have good Equals/GetHashCode
- public DependencyNodeCore<DependencyContextType> Node;
- public DependencyNodeCore<DependencyContextType> OtherReasonNode;
- public string Reason;
+ public readonly DependencyNodeCore<DependencyContextType> Node;
+ public readonly DependencyNodeCore<DependencyContextType> OtherReasonNode;
+ public readonly string Reason;
+
+ public override bool Equals(object obj)
+ {
+ return obj is CombinedDependencyListEntry && Equals((CombinedDependencyListEntry)obj);
+ }
+
+ public override int GetHashCode()
+ {
+ int hash = 23;
+ hash = hash * 31 + Node.GetHashCode();
+
+ if (OtherReasonNode != null)
+ hash = hash * 31 + OtherReasonNode.GetHashCode();
+
+ if (Reason != null)
+ hash = hash * 31 + Reason.GetHashCode();
+
+ return hash;
+ }
+
+ public bool Equals(CombinedDependencyListEntry other)
+ {
+ return Object.ReferenceEquals(Node, other.Node)
+ && Object.ReferenceEquals(OtherReasonNode, other.OtherReasonNode)
+ && Object.Equals(Reason, other.Reason);
+ }
}
public abstract bool InterestingForDynamicDependencyAnalysis