From 4eb6b02f0898413b3c13bdb46926492b3efc3949 Mon Sep 17 00:00:00 2001 From: Pawel Kozlowski Date: Wed, 27 Mar 2019 14:19:15 +0100 Subject: [PATCH] refactor(ivy): remove forEach usage in ApplicationRef.tick (#29543) forEach is slower as compared to a regular loop but more importantly this change removes an anonymous function and thus makes stack traces shorter and easier to read (important for perf analysis). PR Close #29543 --- packages/core/src/application_ref.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/core/src/application_ref.ts b/packages/core/src/application_ref.ts index 0efd77d2af..e6a2faf3dd 100644 --- a/packages/core/src/application_ref.ts +++ b/packages/core/src/application_ref.ts @@ -630,9 +630,13 @@ export class ApplicationRef { const scope = ApplicationRef._tickScope(); try { this._runningTick = true; - this._views.forEach((view) => view.detectChanges()); + for (let view of this._views) { + view.detectChanges(); + } if (this._enforceNoNewChanges) { - this._views.forEach((view) => view.checkNoChanges()); + for (let view of this._views) { + view.checkNoChanges(); + } } } catch (e) { // Attention: Don't rethrow as it could cancel subscriptions to Observables!