From 868303557dbb18c78a074897a9f7451bdc51509c Mon Sep 17 00:00:00 2001 From: CyrusNajmabadi Date: Sat, 12 Nov 2016 13:17:08 -0800 Subject: [PATCH] Use tuples in more cases. --- .../Shared/Collections/IntervalTree`1.cs | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Workspaces/Core/Portable/Shared/Collections/IntervalTree`1.cs b/src/Workspaces/Core/Portable/Shared/Collections/IntervalTree`1.cs index 48a4b38d834..becc5890688 100644 --- a/src/Workspaces/Core/Portable/Shared/Collections/IntervalTree`1.cs +++ b/src/Workspaces/Core/Portable/Shared/Collections/IntervalTree`1.cs @@ -113,16 +113,16 @@ private IEnumerable GetInOrderIntervals(int start, int length, TestInterval t var end = start + length; // The bool indicates if this is the first time we are seeing the node. - var candidates = new Stack>(); - candidates.Push(ValueTuple.Create(root, true)); + var candidates = new Stack<(Node node, bool firstTime)>(); + candidates.Push((root, true)); while (candidates.Count > 0) { var currentTuple = candidates.Pop(); - var currentNode = currentTuple.Item1; + var currentNode = currentTuple.node; Debug.Assert(currentNode != null); - var firstTime = currentTuple.Item2; + var firstTime = currentTuple.firstTime; if (!firstTime) { @@ -148,18 +148,18 @@ private IEnumerable GetInOrderIntervals(int start, int length, TestInterval t var right = currentNode.Right; if (right != null && GetEnd(right.MaxEndNode.Value, introspector) >= start) { - candidates.Push(ValueTuple.Create(right, true)); + candidates.Push((right, firstTime: true)); } } - candidates.Push(ValueTuple.Create(currentNode, false)); + candidates.Push((currentNode, firstTime: false)); // only if left's maxVal overlaps with interval's start, we should consider // left subtree var left = currentNode.Left; if (left != null && GetEnd(left.MaxEndNode.Value, introspector) >= start) { - candidates.Push(ValueTuple.Create(left, true)); + candidates.Push((left, firstTime: true)); } } } @@ -243,22 +243,22 @@ public IEnumerator GetEnumerator() } // The bool indicates if this is the first time we are seeing the node. - var candidates = new Stack>(); + var candidates = new Stack<(Node node, bool firstTime)>(); candidates.Push(ValueTuple.Create(root, true)); while (candidates.Count != 0) { var currentTuple = candidates.Pop(); - var currentNode = currentTuple.Item1; + var currentNode = currentTuple.node; if (currentNode != null) { - if (currentTuple.Item2) + if (currentTuple.firstTime) { // First time seeing this node. Mark that we've been seen and recurse // down the left side. The next time we see this node we'll yield it // out. - candidates.Push(ValueTuple.Create(currentNode.Right, true)); - candidates.Push(ValueTuple.Create(currentNode, false)); - candidates.Push(ValueTuple.Create(currentNode.Left, true)); + candidates.Push((currentNode.Right, firstTime: true)); + candidates.Push((currentNode, firstTime: false)); + candidates.Push((currentNode.Left, firstTime: true)); } else { -- GitLab