Introduce FirstOrDefault extensions method for Array.Find and List.Find.
This allows the LINQ spelling to be used, but benefits from the performance improvement of the specific methods for these classes that provide the same result.
This commit is contained in:
@@ -9,7 +9,6 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Mods.Common.Activities;
|
||||
@@ -163,7 +162,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (world.Map.Contains(cell))
|
||||
{
|
||||
var explored = subject.Actor.Owner.Shroud.IsExplored(cell);
|
||||
var cannotMove = Array.Find(subjects, a => !a.Trait.Info.MoveIntoShroud).Trait;
|
||||
var cannotMove = subjects.FirstOrDefault(a => !a.Trait.Info.MoveIntoShroud).Trait;
|
||||
var blocked = !explored && cannotMove != null;
|
||||
|
||||
if (isAssaultMove)
|
||||
|
||||
Reference in New Issue
Block a user