Optimize IndexOfFrame function in TAStudio
This commit is contained in:
parent
87197e0524
commit
05abb3adfa
|
@ -290,14 +290,19 @@ namespace BizHawk.Client.Common
|
||||||
{
|
{
|
||||||
public static int IndexOfFrame(this IList<TasBranch> list, int frame)
|
public static int IndexOfFrame(this IList<TasBranch> list, int frame)
|
||||||
{
|
{
|
||||||
var branch = list
|
// intentionally not using linq here because this is called many times per frame
|
||||||
.Where(b => b.Frame == frame)
|
int index = -1;
|
||||||
.OrderByDescending(b => b.TimeStamp)
|
var timeStamp = DateTime.MaxValue;
|
||||||
.FirstOrDefault();
|
for (int i = 0; i < list.Count; i++)
|
||||||
|
{
|
||||||
|
if (list[i].Frame == frame && list[i].TimeStamp < timeStamp)
|
||||||
|
{
|
||||||
|
index = i;
|
||||||
|
timeStamp = list[i].TimeStamp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return branch == null
|
return index;
|
||||||
? -1
|
|
||||||
: list.IndexOf(branch);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: stop relying on the index value of a branch
|
// TODO: stop relying on the index value of a branch
|
||||||
|
|
Loading…
Reference in New Issue