perf(ivy): stricter null checks (#31839)

PR Close #31839
This commit is contained in:
Pawel Kozlowski 2019-07-26 11:52:15 +02:00 committed by Andrew Kushnir
parent c0317d40c9
commit 561ec6a5be
3 changed files with 17 additions and 12 deletions

View File

@ -185,18 +185,23 @@ export function executeHooks(
checkNoChangesMode: boolean, initPhaseState: InitPhaseState,
currentNodeIndex: number | null | undefined): void {
if (checkNoChangesMode) return;
const hooksToCall = (currentView[FLAGS] & LViewFlags.InitPhaseStateMask) === initPhaseState ?
firstPassHooks :
checkHooks;
if (hooksToCall) {
callHooks(currentView, hooksToCall, initPhaseState, currentNodeIndex);
if (checkHooks !== null || firstPassHooks !== null) {
const hooksToCall = (currentView[FLAGS] & LViewFlags.InitPhaseStateMask) === initPhaseState ?
firstPassHooks :
checkHooks;
if (hooksToCall !== null) {
callHooks(currentView, hooksToCall, initPhaseState, currentNodeIndex);
}
}
// The init phase state must be always checked here as it may have been recursively updated
if (currentNodeIndex == null &&
(currentView[FLAGS] & LViewFlags.InitPhaseStateMask) === initPhaseState &&
let flags = currentView[FLAGS];
if (currentNodeIndex == null && (flags & LViewFlags.InitPhaseStateMask) === initPhaseState &&
initPhaseState !== InitPhaseState.InitPhaseCompleted) {
currentView[FLAGS] &= LViewFlags.IndexWithinInitPhaseReset;
currentView[FLAGS] += LViewFlags.InitPhaseStateIncrementer;
flags &= LViewFlags.IndexWithinInitPhaseReset;
flags += LViewFlags.InitPhaseStateIncrementer;
currentView[FLAGS] = flags;
}
}

View File

@ -120,7 +120,7 @@ export function refreshDescendantViews(lView: LView) {
export function setHostBindings(tView: TView, viewData: LView): void {
const selectedIndex = getSelectedIndex();
try {
if (tView.expandoInstructions) {
if (tView.expandoInstructions !== null) {
let bindingRootIndex = viewData[BINDING_INDEX] = tView.expandoStartIndex;
setBindingRoot(bindingRootIndex);
let currentDirectiveIndex = -1;

View File

@ -167,8 +167,8 @@ let activeDirectiveSuperClassHeight = 0;
*/
export function setActiveHostElement(elementIndex: number | null = null) {
if (_selectedIndex !== elementIndex) {
setSelectedIndex(elementIndex == null ? -1 : elementIndex);
activeDirectiveId = elementIndex == null ? 0 : MIN_DIRECTIVE_ID;
setSelectedIndex(elementIndex === null ? -1 : elementIndex);
activeDirectiveId = elementIndex === null ? 0 : MIN_DIRECTIVE_ID;
activeDirectiveSuperClassDepthPosition = 0;
activeDirectiveSuperClassHeight = 0;
}