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:
RoosterDragon
2023-11-04 12:11:31 +00:00
committed by Gustas
parent 5157bc375d
commit 0c2d060d43
2 changed files with 63 additions and 40 deletions

View File

@@ -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);
}
}
}