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
This commit is contained in:
parent
860b5d0efa
commit
e3422e0aed
|
@ -377,10 +377,7 @@ export function refreshView<T>(
|
||||||
try {
|
try {
|
||||||
resetPreOrderHookFlags(lView);
|
resetPreOrderHookFlags(lView);
|
||||||
|
|
||||||
// Resetting the bindingIndex of the current LView as the next steps may trigger change
|
setBindingRoot(lView[BINDING_INDEX] = tView.bindingStartIndex);
|
||||||
// detection.
|
|
||||||
lView[BINDING_INDEX] = tView.bindingStartIndex;
|
|
||||||
|
|
||||||
if (templateFn !== null) {
|
if (templateFn !== null) {
|
||||||
executeTemplate(lView, templateFn, RenderFlags.Update, context);
|
executeTemplate(lView, templateFn, RenderFlags.Update, context);
|
||||||
}
|
}
|
||||||
|
@ -463,7 +460,6 @@ export function refreshView<T>(
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
lView[FLAGS] &= ~(LViewFlags.Dirty | LViewFlags.FirstLViewPass);
|
lView[FLAGS] &= ~(LViewFlags.Dirty | LViewFlags.FirstLViewPass);
|
||||||
lView[BINDING_INDEX] = tView.bindingStartIndex;
|
|
||||||
leaveView(oldView);
|
leaveView(oldView);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -414,10 +414,6 @@ export function setCurrentQueryIndex(value: number): void {
|
||||||
export function enterView(newView: LView, hostTNode: TElementNode | TViewNode | null): LView {
|
export function enterView(newView: LView, hostTNode: TElementNode | TViewNode | null): LView {
|
||||||
ngDevMode && assertLViewOrUndefined(newView);
|
ngDevMode && assertLViewOrUndefined(newView);
|
||||||
const oldView = lView;
|
const oldView = lView;
|
||||||
if (newView) {
|
|
||||||
const tView = newView[TVIEW];
|
|
||||||
bindingRootIndex = tView.bindingStartIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
previousOrParentTNode = hostTNode !;
|
previousOrParentTNode = hostTNode !;
|
||||||
isParent = true;
|
isParent = true;
|
||||||
|
|
Loading…
Reference in New Issue