@@ -10006,26 +10006,25 @@ export function tryParsePattern(pattern: string): string | Pattern | undefined {
1000610006/** @internal */
1000710007export interface ParsedPatterns {
1000810008 matchableStringSet : ReadonlySet < string > | undefined ;
10009- sortedPatterns : ( readonly Pattern [ ] ) | undefined ;
10009+ patterns : ( readonly Pattern [ ] ) | undefined ;
1001010010}
1001110011
1001210012const parsedPatternsCache = new WeakMap < MapLike < string [ ] > , ParsedPatterns > ( ) ;
1001310013
1001410014/**
10015- * Divides patterns into a set of exact specifiers and sorted patterns.
10016- * NOTE that this function caches, and assumes the same `paths` argument will
10017- * never be provided with a different value for `sortByAggregateLength`.
10015+ * Divides patterns into a set of exact specifiers and patterns.
10016+ * NOTE that this function caches the result based on object identity.
1001810017 *
1001910018 * @internal
1002010019 */
10021- export function tryParsePatterns ( paths : MapLike < string [ ] > , sortByAggregateLength : boolean = false ) : ParsedPatterns {
10020+ export function tryParsePatterns ( paths : MapLike < string [ ] > ) : ParsedPatterns {
1002210021 let result = parsedPatternsCache . get ( paths ) ;
1002310022 if ( result !== undefined ) {
1002410023 return result ;
1002510024 }
1002610025
1002710026 let matchableStringSet : Set < string > | undefined ;
10028- let sortedPatterns : Pattern [ ] | undefined ;
10027+ let patterns : Pattern [ ] | undefined ;
1002910028
1003010029 const pathList = getOwnKeys ( paths ) ;
1003110030 for ( const path of pathList ) {
@@ -10037,23 +10036,15 @@ export function tryParsePatterns(paths: MapLike<string[]>, sortByAggregateLength
1003710036 ( matchableStringSet ??= new Set ( ) ) . add ( patternOrStr ) ;
1003810037 }
1003910038 else {
10040- ( sortedPatterns ??= [ ] ) . push ( patternOrStr ) ;
10039+ ( patterns ??= [ ] ) . push ( patternOrStr ) ;
1004110040 }
1004210041 }
1004310042
10044- sortedPatterns ?. sort ( ( a , b ) => {
10045- const prefixComparison = compareStringsCaseSensitive ( a . prefix , b . prefix ) ;
10046- if ( prefixComparison === 0 && sortByAggregateLength ) {
10047- return a . suffix . length - b . suffix . length ;
10048- }
10049- return prefixComparison ;
10050- } ) ;
10051-
1005210043 parsedPatternsCache . set (
1005310044 paths ,
1005410045 result = {
1005510046 matchableStringSet,
10056- sortedPatterns ,
10047+ patterns ,
1005710048 } ,
1005810049 ) ;
1005910050
@@ -10121,17 +10112,17 @@ export const emptyFileSystemEntries: FileSystemEntries = {
1012110112 * @internal
1012210113 */
1012310114export function matchPatternOrExact ( patternOrStrings : ParsedPatterns , candidate : string ) : string | Pattern | undefined {
10124- const { matchableStringSet, sortedPatterns } = patternOrStrings ;
10115+ const { matchableStringSet, patterns } = patternOrStrings ;
1012510116
1012610117 if ( matchableStringSet ?. has ( candidate ) ) {
1012710118 return candidate ;
1012810119 }
1012910120
10130- if ( sortedPatterns === undefined || sortedPatterns . length === 0 ) {
10121+ if ( patterns === undefined || patterns . length === 0 ) {
1013110122 return undefined ;
1013210123 }
1013310124
10134- return findBestPatternMatch ( sortedPatterns , _ => _ , candidate ) ;
10125+ return findBestPatternMatch ( patterns , _ => _ , candidate ) ;
1013510126}
1013610127
1013710128/** @internal */
0 commit comments