Hi good people, I’ll go straight to the point. C# script.
I was sorting a List
like this:
mColliders.Sort( (a, b) => ((a.Up.x-a.Radius).CompareTo(b.Up.x-b.Radius)));
and the performance on a ~250 long list were horrible, both in the editor and on the iPhone, roughly 3ms.
Then, just to test, I rewrote it with a dumb lamda like this:
mColliders.Sort( (a, b) => {
if (a.Up.x-a.Radius>b.Up.x-b.Radius) return 1;
else if (a.Up.x-a.Radius<b.Up.x-b.Radius) return -1;
else return 0;
});
Much better, went down to ~0.6ms.
Does anybody here have an idea of why the CompareTo was being so damn slow?
Thanks!