未验证 提交 b518cfb3 编写于 作者: S Stephen Toub 提交者: GitHub

Change most non-generic sorts to be generic (#6285)

Especially for the sorts based on int[], this avoids boxing potentially huge numbers of ints.  Even for classes, it avoids unnecessary casting, and switching to a delegate avoids a top-level allocation for the comparer inside the current Array.Sort implementation.
上级 99495097
......@@ -27,17 +27,6 @@ public Coordinate(double v, int i)
}
}
internal class CoordinateComparer : IComparer
{
int IComparer.Compare(Object x, Object y)
{
double vx = ((Coordinate)x).value;
double vy = ((Coordinate)y).value;
return vx.CompareTo(vy);
}
}
internal class CoordinateSearcher : IComparer
{
int IComparer.Compare(Object x, Object y)
......@@ -237,10 +226,10 @@ private void SortEndPoints(DisplayList dl, int count)
AddPoint(p, count + 1, Double.MaxValue, Double.MaxValue);
Array.Sort(_xCoord, new CoordinateComparer());
Array.Sort(_xCoord, (x, y) => x.value.CompareTo(y.value));
_xCount = _xCoord.Length;
Array.Sort(_yCoord, new CoordinateComparer());
Array.Sort(_yCoord, (x, y) => x.value.CompareTo(y.value));
_yCount = _yCoord.Length;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册