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, checkNoChangesMode: boolean, initPhaseState: InitPhaseState,
currentNodeIndex: number | null | undefined): void { currentNodeIndex: number | null | undefined): void {
if (checkNoChangesMode) return; if (checkNoChangesMode) return;
const hooksToCall = (currentView[FLAGS] & LViewFlags.InitPhaseStateMask) === initPhaseState ?
firstPassHooks : if (checkHooks !== null || firstPassHooks !== null) {
checkHooks; const hooksToCall = (currentView[FLAGS] & LViewFlags.InitPhaseStateMask) === initPhaseState ?
if (hooksToCall) { firstPassHooks :
callHooks(currentView, hooksToCall, initPhaseState, currentNodeIndex); 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 // The init phase state must be always checked here as it may have been recursively updated
if (currentNodeIndex == null && let flags = currentView[FLAGS];
(currentView[FLAGS] & LViewFlags.InitPhaseStateMask) === initPhaseState && if (currentNodeIndex == null && (flags & LViewFlags.InitPhaseStateMask) === initPhaseState &&
initPhaseState !== InitPhaseState.InitPhaseCompleted) { initPhaseState !== InitPhaseState.InitPhaseCompleted) {
currentView[FLAGS] &= LViewFlags.IndexWithinInitPhaseReset; flags &= LViewFlags.IndexWithinInitPhaseReset;
currentView[FLAGS] += LViewFlags.InitPhaseStateIncrementer; 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 { export function setHostBindings(tView: TView, viewData: LView): void {
const selectedIndex = getSelectedIndex(); const selectedIndex = getSelectedIndex();
try { try {
if (tView.expandoInstructions) { if (tView.expandoInstructions !== null) {
let bindingRootIndex = viewData[BINDING_INDEX] = tView.expandoStartIndex; let bindingRootIndex = viewData[BINDING_INDEX] = tView.expandoStartIndex;
setBindingRoot(bindingRootIndex); setBindingRoot(bindingRootIndex);
let currentDirectiveIndex = -1; let currentDirectiveIndex = -1;

View File

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