Skip to content
This repository was archived by the owner on Jul 12, 2022. It is now read-only.

Commit 7de79cb

Browse files
committed
Remove unnecessary IEquatable implementations
comparison operators, overloads, etc. These were left over from thinking about the original algorithm.
1 parent c1416c8 commit 7de79cb

4 files changed

Lines changed: 5 additions & 50 deletions

File tree

src/Microsoft.DotNet.DeadRegionAnalysis/AnalysisEngine.RegionRemoval.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,7 @@ private static string GetReplacementText(DirectiveTriviaSyntax startDirective, D
155155

156156
private static int CompareTextChanges(TextChange x, TextChange y)
157157
{
158-
int result = x.Span.End - y.Span.End;
159-
if (result == 0)
160-
{
161-
return x.Span.Start - y.Span.Start;
162-
}
163-
164-
return result;
158+
return x.Span.CompareTo(y.Span);
165159
}
166160

167161
private static List<TextChange> MergeOverlappingRegions(List<TextChange> changes)

src/Microsoft.DotNet.DeadRegionAnalysis/ConditionalRegion.cs

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Microsoft.DotNet.DeadRegionAnalysis
1313
{
14-
public class ConditionalRegion : IComparable<ConditionalRegion>, IEquatable<ConditionalRegion>
14+
public class ConditionalRegion : IComparable<ConditionalRegion>
1515
{
1616
public DirectiveTriviaSyntax StartDirective { get; private set; }
1717

@@ -61,7 +61,7 @@ public int CompareTo(ConditionalRegion other)
6161
{
6262
if (other == null)
6363
{
64-
return 1;
64+
return -1;
6565
}
6666

6767
int result = SpanStart - other.SpanStart;
@@ -73,41 +73,6 @@ public int CompareTo(ConditionalRegion other)
7373
return result;
7474
}
7575

76-
public bool Equals(ConditionalRegion other)
77-
{
78-
return CompareTo(other) == 0;
79-
}
80-
81-
public override bool Equals(object obj)
82-
{
83-
return Equals(obj as ConditionalRegion);
84-
}
85-
86-
public override int GetHashCode()
87-
{
88-
return base.GetHashCode();
89-
}
90-
91-
public static bool operator ==(ConditionalRegion x, ConditionalRegion y)
92-
{
93-
if (object.Equals(x, y))
94-
{
95-
return true;
96-
}
97-
98-
return x.Equals(y);
99-
}
100-
101-
public static bool operator !=(ConditionalRegion x, ConditionalRegion y)
102-
{
103-
if (object.Equals(x, y))
104-
{
105-
return false;
106-
}
107-
108-
return !x.Equals(y);
109-
}
110-
11176
public override string ToString()
11277
{
11378
string stateString =

src/Microsoft.DotNet.DeadRegionAnalysis/ConditionalRegionChain.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
namespace Microsoft.DotNet.DeadRegionAnalysis
99
{
10-
public struct ConditionalRegionChain : IComparable<ConditionalRegionChain>, IEquatable<ConditionalRegionChain>
10+
public struct ConditionalRegionChain : IComparable<ConditionalRegionChain>
1111
{
1212
private ImmutableArray<ConditionalRegion> _regions;
1313

@@ -48,10 +48,5 @@ public int CompareTo(ConditionalRegionChain other)
4848

4949
return result;
5050
}
51-
52-
public bool Equals(ConditionalRegionChain other)
53-
{
54-
return CompareTo(other) == 0;
55-
}
5651
}
5752
}

src/Microsoft.DotNet.DeadRegionAnalysis/Microsoft.DotNet.DeadRegionAnalysis.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
<Compile Include="ConditionalRegionChain.cs" />
8888
<Compile Include="DirectiveTriviaSyntaxExtensions.cs" />
8989
<Compile Include="DocumentConditionalRegionInfo.cs" />
90+
<Compile Include="IAnalysisLogger.cs" />
9091
<Compile Include="PreprocessorExpressionSimplifier.cs" />
9192
<Compile Include="PreprocessorExpressionEvaluator.cs" />
9293
<Compile Include="PreprocessorSymbolTracker.cs" />

0 commit comments

Comments
 (0)