@@ -34,6 +34,7 @@ export class ProjectChangeAnalyzer {
34
34
* undefined === data isn't available (i.e. - git isn't present)
35
35
*/
36
36
private _data : Map < string , Map < string , string > > | undefined | UNINITIALIZED = UNINITIALIZED ;
37
+ private _filteredData : Map < string , Map < string , string > > = new Map < string , Map < string , string > > ( ) ;
37
38
private _projectStateCache : Map < string , string > = new Map < string , string > ( ) ;
38
39
private _rushConfiguration : RushConfiguration ;
39
40
private readonly _git : Git ;
@@ -55,6 +56,12 @@ export class ProjectChangeAnalyzer {
55
56
projectName : string ,
56
57
terminal : Terminal
57
58
) : Promise < Map < string , string > | undefined > {
59
+ // Check the cache for any existing data
60
+ const existingData : Map < string , string > | undefined = this . _filteredData . get ( projectName ) ;
61
+ if ( existingData ) {
62
+ return existingData ;
63
+ }
64
+
58
65
if ( this . _data === UNINITIALIZED ) {
59
66
this . _data = await this . _getDataAsync ( terminal ) ;
60
67
}
@@ -70,22 +77,26 @@ export class ProjectChangeAnalyzer {
70
77
}
71
78
72
79
const unfilteredProjectData : Map < string , string > = this . _data . get ( projectName ) ! ;
73
- const filteredProjectData : Map < string , string > = new Map ( unfilteredProjectData ) ;
80
+ let filteredProjectData : Map < string , string > | undefined ;
74
81
75
82
const ignoreMatcher : Ignore | undefined = await this . _getIgnoreMatcherForProjectAsync ( project , terminal ) ;
76
83
if ( ignoreMatcher ) {
77
84
// At this point, `filePath` is guaranteed to start with `projectRelativeFolder`, so
78
85
// we can safely slice off the first N characters to get the file path relative to the
79
86
// root of the project.
80
- for ( const [ filePath ] of unfilteredProjectData ) {
87
+ filteredProjectData = new Map < string , string > ( ) ;
88
+ for ( const [ filePath , fileHash ] of unfilteredProjectData ) {
81
89
const relativePath : string = filePath . slice ( project . projectRelativeFolder . length + 1 ) ;
82
- if ( ignoreMatcher . ignores ( relativePath ) ) {
83
- // Remove from the filtered data as we encounter the ignored files
84
- filteredProjectData . delete ( filePath ) ;
90
+ if ( ! ignoreMatcher . ignores ( relativePath ) ) {
91
+ // Add the file path to the filtered data if it is not ignored
92
+ filteredProjectData . set ( filePath , fileHash ) ;
85
93
}
86
94
}
95
+ } else {
96
+ filteredProjectData = unfilteredProjectData ;
87
97
}
88
98
99
+ this . _filteredData . set ( projectName , filteredProjectData ) ;
89
100
return filteredProjectData ;
90
101
}
91
102
@@ -189,7 +200,7 @@ export class ProjectChangeAnalyzer {
189
200
owningProjectHashDeps = new Map < string , string > ( ) ;
190
201
projectHashDeps . set ( owningProject . packageName , owningProjectHashDeps ) ;
191
202
}
192
- owningProjectHashDeps ! . set ( filePath , fileHash ) ;
203
+ owningProjectHashDeps . set ( filePath , fileHash ) ;
193
204
}
194
205
}
195
206
0 commit comments