Skip to content

Commit a488d70

Browse files
author
Kapil Borle
committed
Remove redundant code in digraph class
1 parent 66a942e commit a488d70

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

Engine/Helper.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3572,7 +3572,10 @@ public Digraph()
35723572
}
35733573

35743574
/// <summary>
3575-
/// Construct digraph with an EqualityComparer used for comparing type T
3575+
/// Construct a directed graph that uses an EqualityComparer object for comparison with its vertices
3576+
///
3577+
/// The class allows its client to use their choice of vertex type. To allow comparison for such a
3578+
/// vertex type, client can pass their own EqualityComparer object
35763579
/// </summary>
35773580
/// <param name="equalityComparer"></param>
35783581
public Digraph(IEqualityComparer<T> equalityComparer) : this()
@@ -3728,21 +3731,18 @@ private bool IsConnected(int fromIdx, int toIdx, ref bool[] visited)
37283731
return true;
37293732
}
37303733

3731-
bool isConnected = false;
37323734
foreach(var vertexIdx in graph[fromIdx])
37333735
{
37343736
if (!visited[vertexIdx])
37353737
{
3736-
isConnected |= IsConnected(vertexIdx, toIdx, ref visited);
3737-
}
3738-
3739-
if (isConnected) // no need to search further
3740-
{
3741-
break;
3738+
if(IsConnected(vertexIdx, toIdx, ref visited))
3739+
{
3740+
return true;
3741+
}
37423742
}
37433743
}
37443744

3745-
return isConnected;
3745+
return false;
37463746
}
37473747

37483748
/// <summary>

Rules/UseShouldProcessCorrectly.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,13 @@ private void FindViolations()
140140
/// <returns>An instance of DiagnosticRecord if it find violation, otherwise null</returns>
141141
private DiagnosticRecord GetViolation(Vertex v)
142142
{
143-
bool callsShouldProcess = funcDigraph.IsConnected(v, shouldProcessVertex);
144143
FunctionDefinitionAst fast = v.Ast as FunctionDefinitionAst;
145144
if (fast == null)
146145
{
147146
return null;
148147
}
149148

149+
bool callsShouldProcess = funcDigraph.IsConnected(v, shouldProcessVertex);
150150
if (DeclaresSupportsShouldProcess(fast))
151151
{
152152
if (!callsShouldProcess)

0 commit comments

Comments
 (0)