Skip to content

Commit 14b1be2

Browse files
committed
refactor(@angular-devkit/build-angular): use for loop instead of filter and forEach
Reduce iterations by using a `for loop`.
1 parent af1f0da commit 14b1be2

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

packages/angular_devkit/build_angular/src/tools/esbuild/bundler-context.ts

+12-8
Original file line numberDiff line numberDiff line change
@@ -234,10 +234,12 @@ export class BundlerContext {
234234
if (this.incremental) {
235235
// When incremental always add any files from the load result cache
236236
if (this.#loadCache) {
237-
this.#loadCache.watchFiles
238-
.filter((file) => !isInternalAngularFile(file))
239-
// watch files are fully resolved paths
240-
.forEach((file) => this.watchFiles.add(file));
237+
for (const file of this.#loadCache.watchFiles) {
238+
if (!isInternalAngularFile(file)) {
239+
// watch files are fully resolved paths
240+
this.watchFiles.add(file);
241+
}
242+
}
241243
}
242244
}
243245
}
@@ -247,10 +249,12 @@ export class BundlerContext {
247249
// currently enabled with watch mode where watch files are needed.
248250
if (this.incremental) {
249251
// Add input files except virtual angular files which do not exist on disk
250-
Object.keys(result.metafile.inputs)
251-
.filter((input) => !isInternalAngularFile(input))
252-
// input file paths are always relative to the workspace root
253-
.forEach((input) => this.watchFiles.add(join(this.workspaceRoot, input)));
252+
for (const input of Object.keys(result.metafile.inputs)) {
253+
if (!isInternalAngularFile(input)) {
254+
// input file paths are always relative to the workspace root
255+
this.watchFiles.add(join(this.workspaceRoot, input));
256+
}
257+
}
254258
}
255259

256260
// Return if the build encountered any errors

0 commit comments

Comments
 (0)