mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-04-12 12:07:05 +00:00
perf: Moving enumerable extensions optimizations into correct place
This commit is contained in:
parent
f53607018c
commit
e21830a7d5
1 changed files with 24 additions and 2 deletions
|
|
@ -58,7 +58,18 @@ namespace ICD.Common.Utils.Extensions
|
|||
if (extends == null)
|
||||
throw new ArgumentNullException("extends");
|
||||
|
||||
return extends.TryFirst(i => true, out item);
|
||||
IList<T> list = extends as IList<T>;
|
||||
if (list == null)
|
||||
return extends.TryFirst(i => true, out item);
|
||||
|
||||
item = default(T);
|
||||
|
||||
if (list.Count <= 0)
|
||||
return false;
|
||||
|
||||
item = list[0];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -106,7 +117,18 @@ namespace ICD.Common.Utils.Extensions
|
|||
if (extends == null)
|
||||
throw new ArgumentNullException("extends");
|
||||
|
||||
return extends.TryLast(i => true, out item);
|
||||
IList<T> list = extends as IList<T>;
|
||||
if (list == null)
|
||||
return extends.TryLast(i => true, out item);
|
||||
|
||||
item = default(T);
|
||||
|
||||
if (list.Count <= 0)
|
||||
return false;
|
||||
|
||||
item = list[list.Count - 1];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue