I have the following method:
private void removeUnnecessaryLines(List<ScatterViewItem> list)
{
List<Line> remove = new List<Line>();
foreach (Line line in lines)
{
SourceFile destination = (line.Tag as Call).getCallee();
foreach (ScatterViewItem svi in list)
{
SourceFile test = svi.Tag as SourceFile;
if (test.Equals(destination))
{
remove.Add(line);
}
}
}
foreach (Line l in remove)
{
lines.Remove(l);
Dependencies.Children.Remove(l);
}
}
As you can see, there is a lot of iteration and casting. Is there a simple way to improve that?