stop using exceptions for flow control
This commit is contained in:
parent
927a8970d6
commit
ac349af9f5
|
@ -108,14 +108,10 @@ namespace BizHawk.Common.CollectionExtensions
|
|||
public static T? FirstOrNull<T>(this IEnumerable<T> list, Func<T, bool> predicate)
|
||||
where T : struct
|
||||
{
|
||||
try
|
||||
{
|
||||
return list.First(predicate);
|
||||
}
|
||||
catch (InvalidOperationException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
foreach (var t in list)
|
||||
if (predicate(t))
|
||||
return t;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue