提交 c2ce421b 编写于 作者: N Neal Gafter

Minor changes per code review.

上级 d46f75ae
......@@ -386,7 +386,7 @@ out ImmutableArray<(BoundExpression, BoundDagTemp)> bindings)
/// when an assertion fails (it is unaffected by exception filters on enclosing frames).
/// </summary>
[Conditional("DEBUG")]
private void Assert(bool condition, string message = null)
private static void Assert(bool condition, string message = null)
{
if (!condition)
{
......@@ -573,7 +573,7 @@ DagState uniqifyState(DagState state)
workList.Free();
// Now process the states in topological order, leaves first, and assign a BoundDecisionDag to each DagState.
ImmutableArray<DagState> sortedStates = initialState.TopologicallySortedReachableStates;
ImmutableArray<DagState> sortedStates = initialState.TopologicallySortedReachableStates();
Debug.Assert(_defaultLabel != null);
var finalStates = PooledDictionary<LabelSymbol, BoundDecisionDag>.GetInstance();
finalStates.Add(_defaultLabel, defaultDecision);
......@@ -935,27 +935,24 @@ public DagState(ImmutableArray<PartialCaseDecision> cases)
public BoundDagDecision SelectedDecision;
public DagState TrueBranch, FalseBranch;
public ImmutableArray<DagState> TopologicallySortedReachableStates
public ImmutableArray<DagState> TopologicallySortedReachableStates()
{
get
// A successor function used to topologically sort the DagState set.
IEnumerable<DagState> succ(DagState state)
{
// A successor function used to topologically sort the DagState set.
IEnumerable<DagState> succ(DagState state)
if (state.TrueBranch != null)
{
if (state.TrueBranch != null)
{
yield return state.TrueBranch;
}
if (state.FalseBranch != null)
{
yield return state.FalseBranch;
}
yield return state.TrueBranch;
}
// Now process the states in topological order, leaves first, and assign a BoundDecisionDag to each DagState.
return TopologicalSort.IterativeSort<DagState>(SpecializedCollections.SingletonEnumerable<DagState>(this), succ);
if (state.FalseBranch != null)
{
yield return state.FalseBranch;
}
}
// Now process the states in topological order, leaves first, and assign a BoundDecisionDag to each DagState.
return TopologicalSort.IterativeSort<DagState>(SpecializedCollections.SingletonEnumerable<DagState>(this), succ);
}
// After the entire graph of DagState objects is complete, we translate each into its Dag.
......@@ -987,7 +984,7 @@ internal BoundDagDecision ComputeSelectedDecision()
/// </summary>
internal string Dump()
{
var allStates = this.TopologicallySortedReachableStates;
var allStates = this.TopologicallySortedReachableStates();
var stateIdentifierMap = PooledDictionary<DagState, int>.GetInstance();
for (int i = 0; i < allStates.Length; i++)
{
......
......@@ -4,7 +4,7 @@
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Threading;
using System.Linq;
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.PooledObjects;
......@@ -84,7 +84,7 @@ bool isSubsumed(BoundPatternSwitchLabel switchLabel)
}
// If no switch sections are subsumed, just return
if (switchSections.Count(s => s.SwitchLabels.Count(l => isSubsumed(l)) != 0) == 0)
if (!switchSections.Any(s => s.SwitchLabels.Any(l => isSubsumed(l))))
{
return;
}
......
......@@ -65,7 +65,7 @@ private void ComputeLabelSet(ImmutableArray<BoundDecisionDag> sortedNodes)
{
// Nodes with more than one predecessor are assigned a label
var hasPredecessor = PooledHashSet<BoundDecisionDag>.GetInstance();
void notePreedecesssor(BoundDecisionDag successor)
void notePredecessor(BoundDecisionDag successor)
{
if (successor != null && !hasPredecessor.Add(successor))
{
......@@ -92,11 +92,11 @@ void notePreedecesssor(BoundDecisionDag successor)
_dagNodeLabels[node] = d.Label;
break;
case BoundEvaluationPoint e:
notePreedecesssor(e.Next);
notePredecessor(e.Next);
break;
case BoundDecisionPoint p:
notePreedecesssor(p.WhenTrue);
notePreedecesssor(p.WhenFalse);
notePredecessor(p.WhenTrue);
notePredecessor(p.WhenFalse);
break;
default:
throw ExceptionUtilities.UnexpectedValue(node.Kind);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册