File tree Expand file tree Collapse file tree
src/Microsoft.ComponentDetection.Common Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -61,7 +61,7 @@ public sealed class CompiledMatcher
6161 private readonly string [ ] patterns ;
6262
6363 public CompiledMatcher ( IEnumerable < string > patterns )
64- : this ( patterns is string [ ] arr ? arr : ( patterns ?? throw new ArgumentNullException ( nameof ( patterns ) ) ) . ToArray ( ) )
64+ : this ( ToArray ( patterns ) )
6565 {
6666 }
6767
@@ -72,6 +72,12 @@ internal CompiledMatcher(string[] patterns)
7272 ValidatePatternElements ( this . patterns ) ;
7373 }
7474
75+ private static string [ ] ToArray ( IEnumerable < string > patterns )
76+ {
77+ ArgumentNullException . ThrowIfNull ( patterns ) ;
78+ return patterns as string [ ] ?? patterns . ToArray ( ) ;
79+ }
80+
7581 public bool IsMatch ( ReadOnlySpan < char > fileName ) => GetFirstMatchingPattern ( fileName , this . patterns ) is not null ;
7682
7783 /// <summary>
You can’t perform that action at this time.
0 commit comments