File tree Expand file tree Collapse file tree 2 files changed +9
-5
lines changed Expand file tree Collapse file tree 2 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -514,12 +514,15 @@ [Pure] public static ReadOnlyCollection<T> AsReadOnly<T>(this T[] array)
514
514
{
515
515
if ( array is null ) throw new ArgumentNullException ( nameof ( array ) ) ;
516
516
if ( default ( T ) is not null ) return array ! ;
517
- return Array . FindAll ( array , Typed < T > . NotNullPredicate ) ! ;
518
- }
519
517
520
- private static class Typed < T >
521
- {
522
- public static readonly Predicate < T ? > NotNullPredicate = static v => v is not null ;
518
+ List < T > results = [ ] ;
519
+ for ( int i = 0 ; i < array . Length ; i ++ )
520
+ {
521
+ T ? item = array [ i ] ;
522
+ if ( item is not null )
523
+ results . Add ( item ) ;
524
+ }
525
+ return results . ToArray ( ) ;
523
526
}
524
527
525
528
}
Original file line number Diff line number Diff line change 1
1
# Chasm.Collections Changelog
2
2
3
3
### v2.4.2 (next)
4
+ - ⚡️ Improved the performance of ` NotNull ` array extension by inlining the ` Array.FindAll ` call;
4
5
- ⚡️ Microoptimized IL code size of ` CollectionExtensions.Add ` extensions;
5
6
6
7
### v2.4.1
You can’t perform that action at this time.
0 commit comments