Skip to content

Commit c21927a

Browse files
committed
Only initialize ignorer when required
1 parent 9e2f410 commit c21927a

1 file changed

Lines changed: 10 additions & 12 deletions

File tree

apps/rush-lib/src/logic/ProjectChangeAnalyzer.ts

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -184,22 +184,21 @@ export class ProjectChangeAnalyzer {
184184
return undefined;
185185
}
186186

187-
const projectHashDeps: Map<string, Map<string, string>> = new Map<string, Map<string, string>>();
187+
const projectHashDeps: Map<string, Map<string, string>> = new Map();
188+
189+
for (const project of this._rushConfiguration.projects) {
190+
projectHashDeps.set(project.packageName, new Map());
191+
}
188192

189193
// Sort each project folder into its own package deps hash
190194
for (const [filePath, fileHash] of repoDeps) {
191195
// findProjectForPosixRelativePath uses LookupByPath, for which lookups are O(K)
192196
// K being the maximum folder depth of any project in rush.json (usually on the order of 3)
193197
const owningProject: RushConfigurationProject | undefined =
194198
this._rushConfiguration.findProjectForPosixRelativePath(filePath);
199+
195200
if (owningProject) {
196-
let owningProjectHashDeps: Map<string, string> | undefined = projectHashDeps.get(
197-
owningProject.packageName
198-
);
199-
if (!owningProjectHashDeps) {
200-
owningProjectHashDeps = new Map<string, string>();
201-
projectHashDeps.set(owningProject.packageName, owningProjectHashDeps);
202-
}
201+
const owningProjectHashDeps: Map<string, string> = projectHashDeps.get(owningProject.packageName)!;
203202
owningProjectHashDeps.set(filePath, fileHash);
204203
}
205204
}
@@ -268,16 +267,15 @@ export class ProjectChangeAnalyzer {
268267
private async _getIgnoreMatcherForProjectAsync(
269268
project: RushConfigurationProject,
270269
terminal: Terminal
271-
): Promise<Ignore> {
270+
): Promise<Ignore | undefined> {
272271
const projectConfiguration: RushProjectConfiguration | undefined =
273272
await RushProjectConfiguration.tryLoadForProjectAsync(project, undefined, terminal);
274-
const ignoreMatcher: Ignore = ignore();
275273

276274
if (projectConfiguration && projectConfiguration.incrementalBuildIgnoredGlobs) {
275+
const ignoreMatcher: Ignore = ignore();
277276
ignoreMatcher.add(projectConfiguration.incrementalBuildIgnoredGlobs);
277+
return ignoreMatcher;
278278
}
279-
280-
return ignoreMatcher;
281279
}
282280

283281
private _getRepoDeps(terminal: Terminal): Map<string, string> | undefined {

0 commit comments

Comments
 (0)