Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Perf readability refactors 2019 08 28 #32370

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/core/src/render3/instructions/element.ts
Expand Up @@ -84,7 +84,7 @@ export function ɵɵelementStart(
ngDevMode && ngDevMode.firstTemplatePass++;
resolveDirectives(tView, lView, tNode, localRefs || null);

const inputData = initializeTNodeInputs(tNode);
const inputData = initializeTNodeInputs(tView, tNode);
if (inputData && inputData.hasOwnProperty('class')) {
tNode.flags |= TNodeFlags.hasClassInput;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/render3/instructions/listener.ts
Expand Up @@ -179,7 +179,7 @@ function listenerInternal(
if (tNode.outputs === undefined) {
// if we create TNode here, inputs must be undefined so we know they still need to be
// checked
tNode.outputs = generatePropertyAliases(tNode, BindingDirection.Output);
tNode.outputs = generatePropertyAliases(tView, tNode, BindingDirection.Output);
}

const outputs = tNode.outputs;
Expand Down
22 changes: 11 additions & 11 deletions packages/core/src/render3/instructions/shared.ts
Expand Up @@ -212,15 +212,15 @@ export function getOrCreateTNode(
// Keep this function short, so that the VM will inline it.
const adjustedIndex = index + HEADER_OFFSET;
const tNode = tView.data[adjustedIndex] as TNode ||
createTNodeAtIndex(tView, tHostNode, adjustedIndex, type, name, attrs, index);
createTNodeAtIndex(tView, tHostNode, adjustedIndex, type, name, attrs);
setPreviousOrParentTNode(tNode, true);
return tNode as TElementNode & TViewNode & TContainerNode & TElementContainerNode &
TProjectionNode & TIcuContainerNode;
}

function createTNodeAtIndex(
tView: TView, tHostNode: TNode | null, adjustedIndex: number, type: TNodeType,
name: string | null, attrs: TAttributes | null, index: number) {
name: string | null, attrs: TAttributes | null) {
const previousOrParentTNode = getPreviousOrParentTNode();
const isParent = getIsParent();
const parent =
Expand All @@ -231,9 +231,10 @@ function createTNodeAtIndex(
const tParentNode = parentInSameView ? parent as TElementNode | TContainerNode : null;
const tNode = tView.data[adjustedIndex] =
createTNode(tView, tParentNode, type, adjustedIndex, name, attrs);
// The first node is not always the one at index 0, in case of i18n, index 0 can be the
// instruction `i18nStart` and the first node has the index 1 or more
if (index === 0 || !tView.firstChild) {
// Assign a pointer to the first child node of a given view. The first node is not always the one
// at index 0, in case of i18n, index 0 can be the instruction `i18nStart` and the first node has
// the index 1 or more, so we can't just check node index.
if (tView.firstChild === null) {
tView.firstChild = tNode;
}
if (previousOrParentTNode) {
Expand Down Expand Up @@ -812,9 +813,8 @@ export function createTNode(
* @param direction whether to consider inputs or outputs
* @returns PropertyAliases|null aggregate of all properties if any, `null` otherwise
*/
export function generatePropertyAliases(tNode: TNode, direction: BindingDirection): PropertyAliases|
null {
const tView = getLView()[TVIEW];
export function generatePropertyAliases(
tView: TView, tNode: TNode, direction: BindingDirection): PropertyAliases|null {
let propStore: PropertyAliases|null = null;
const start = tNode.directiveStart;
const end = tNode.directiveEnd;
Expand Down Expand Up @@ -864,7 +864,7 @@ export function elementPropertyInternal<T>(
const tNode = getTNode(index, lView);
let inputData: PropertyAliases|null|undefined;
let dataValue: PropertyAliasValue|undefined;
if (!nativeOnly && (inputData = initializeTNodeInputs(tNode)) &&
if (!nativeOnly && (inputData = initializeTNodeInputs(lView[TVIEW], tNode)) &&
(dataValue = inputData[propName])) {
setInputsForProperty(lView, dataValue, value);
if (isComponent(tNode)) markDirtyIfOnPush(lView, index + HEADER_OFFSET);
Expand Down Expand Up @@ -1785,12 +1785,12 @@ export function storeBindingMetadata(lView: LView, prefix = '', suffix = ''): st

export const CLEAN_PROMISE = _CLEAN_PROMISE;

export function initializeTNodeInputs(tNode: TNode): PropertyAliases|null {
export function initializeTNodeInputs(tView: TView, tNode: TNode): PropertyAliases|null {
// If tNode.inputs is undefined, a listener has created outputs, but inputs haven't
// yet been checked.
if (tNode.inputs === undefined) {
// mark inputs as checked
tNode.inputs = generatePropertyAliases(tNode, BindingDirection.Input);
tNode.inputs = generatePropertyAliases(tView, tNode, BindingDirection.Input);
}
return tNode.inputs;
}
Expand Down