Skip to content

Commit e3422e0

Browse files
pkozlowski-opensourceatscott
authored andcommitted
perf(ivy): minimise writes to the lView[BINDING_INDEX] / binding root (#32263)
This commit removes all the (duplicated) logic of setting lView[BINDING_INDEX] from `enterView`. `enterView` is on the critcal path perf-wise so we should avoid having any logic in there and minimise memory read / write. This simple refactoring in this PR reduces time spent in noop change detection by ~12% (from ~800ms down to ~700ms on a local machine where measurements were taken). PR Close #32263
1 parent 860b5d0 commit e3422e0

File tree

2 files changed

+1
-9
lines changed

2 files changed

+1
-9
lines changed

packages/core/src/render3/instructions/shared.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -377,10 +377,7 @@ export function refreshView<T>(
377377
try {
378378
resetPreOrderHookFlags(lView);
379379

380-
// Resetting the bindingIndex of the current LView as the next steps may trigger change
381-
// detection.
382-
lView[BINDING_INDEX] = tView.bindingStartIndex;
383-
380+
setBindingRoot(lView[BINDING_INDEX] = tView.bindingStartIndex);
384381
if (templateFn !== null) {
385382
executeTemplate(lView, templateFn, RenderFlags.Update, context);
386383
}
@@ -463,7 +460,6 @@ export function refreshView<T>(
463460

464461
} finally {
465462
lView[FLAGS] &= ~(LViewFlags.Dirty | LViewFlags.FirstLViewPass);
466-
lView[BINDING_INDEX] = tView.bindingStartIndex;
467463
leaveView(oldView);
468464
}
469465
}

packages/core/src/render3/state.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -414,10 +414,6 @@ export function setCurrentQueryIndex(value: number): void {
414414
export function enterView(newView: LView, hostTNode: TElementNode | TViewNode | null): LView {
415415
ngDevMode && assertLViewOrUndefined(newView);
416416
const oldView = lView;
417-
if (newView) {
418-
const tView = newView[TVIEW];
419-
bindingRootIndex = tView.bindingStartIndex;
420-
}
421417

422418
previousOrParentTNode = hostTNode !;
423419
isParent = true;

0 commit comments

Comments
 (0)