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;
|
||||
@@ -95,7 +94,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return;
|
||||
|
||||
var currentTransform = self.CurrentActivity as Transform;
|
||||
var transform = Array.Find(transforms, t => !t.IsTraitDisabled && !t.IsTraitPaused);
|
||||
var transform = transforms.FirstOrDefault(t => !t.IsTraitDisabled && !t.IsTraitPaused);
|
||||
if (transform == null && currentTransform == null)
|
||||
return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user