Skip to content

Commit 83729fe

Browse files
committed
Added using block to dispose iterator.
1 parent 8eaa7ce commit 83729fe

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

UI/MemoryViewControl.cs

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -872,29 +872,31 @@ private static IEnumerable<List<HotSpot>> PartitionSelectedNodes(IEnumerable<Hot
872872
{
873873
Contract.Requires(selection != null);
874874

875-
var it = selection.GetEnumerator();
876-
if (!it.MoveNext())
875+
List<HotSpot> partition;
876+
using (var it = selection.GetEnumerator())
877877
{
878-
yield break;
879-
}
878+
if (!it.MoveNext())
879+
{
880+
yield break;
881+
}
880882

881-
var partition = new List<HotSpot>();
882-
partition.Add(it.Current);
883+
partition = new List<HotSpot> { it.Current };
883884

884-
var last = it.Current;
885+
var last = it.Current;
885886

886-
while (it.MoveNext())
887-
{
888-
if (it.Current.Address != last.Address + last.Node.MemorySize)
887+
while (it.MoveNext())
889888
{
890-
yield return partition;
889+
if (it.Current.Address != last.Address + last.Node.MemorySize)
890+
{
891+
yield return partition;
891892

892-
partition = new List<HotSpot>();
893-
}
893+
partition = new List<HotSpot>();
894+
}
894895

895-
partition.Add(it.Current);
896+
partition.Add(it.Current);
896897

897-
last = it.Current;
898+
last = it.Current;
899+
}
898900
}
899901

900902
if (partition.Count != 0)

0 commit comments

Comments
 (0)