Use Array.IndexOf to speed up Shroud.Tick.
As the `touched` cell layer uses Boolean values, Array.IndexOf is able to use a fast vectorised search. Most values in the array are false, so the search is able to significantly improve the performance of finding the next true value in the array.
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using OpenRA.Primitives;
|
||||
|
||||
namespace OpenRA
|
||||
@@ -53,5 +54,15 @@ namespace OpenRA
|
||||
{
|
||||
return Bounds.Contains(uv.U, uv.V);
|
||||
}
|
||||
|
||||
public int IndexOf(T value, int startIndex)
|
||||
{
|
||||
return Array.IndexOf(Entries, value, startIndex);
|
||||
}
|
||||
|
||||
public void SetAll(T value)
|
||||
{
|
||||
Array.Fill(Entries, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user