perf(ivy): guard directive-related operations with a TNode flag (#32445)

PR Close #32445
This commit is contained in:
Pawel Kozlowski
2019-09-02 15:17:44 +02:00
committed by Miško Hevery
parent a383a5a165
commit 641c5c1c1e
16 changed files with 87 additions and 57 deletions

View File

@ -45,23 +45,28 @@ export const enum TNodeType {
* Corresponds to the TNode.flags property.
*/
export const enum TNodeFlags {
/** This bit is set if the node is a component */
isComponent = 0b000001,
/** This bit is set if the node is a host for any directive (including a component) */
isDirectiveHost = 0b00000001,
/**
* This bit is set if the node is a host for a component. Setting this bit implies that the
* isDirectiveHost bit is set as well. */
isComponentHost = 0b00000010,
/** This bit is set if the node has been projected */
isProjected = 0b000010,
isProjected = 0b00000100,
/** This bit is set if any directive on this node has content queries */
hasContentQuery = 0b000100,
hasContentQuery = 0b00001000,
/** This bit is set if the node has any "class" inputs */
hasClassInput = 0b001000,
hasClassInput = 0b00010000,
/** This bit is set if the node has any "style" inputs */
hasStyleInput = 0b010000,
hasStyleInput = 0b00100000,
/** This bit is set if the node has been detached by i18n */
isDetached = 0b100000,
isDetached = 0b01000000,
}
/**

View File

@ -34,8 +34,12 @@ export function isContentQueryHost(tNode: TNode): boolean {
return (tNode.flags & TNodeFlags.hasContentQuery) !== 0;
}
export function isComponent(tNode: TNode): boolean {
return (tNode.flags & TNodeFlags.isComponent) === TNodeFlags.isComponent;
export function isComponentHost(tNode: TNode): boolean {
return (tNode.flags & TNodeFlags.isComponentHost) === TNodeFlags.isComponentHost;
}
export function isDirectiveHost(tNode: TNode): boolean {
return (tNode.flags & TNodeFlags.isDirectiveHost) === TNodeFlags.isDirectiveHost;
}
export function isComponentDef<T>(def: DirectiveDef<T>): def is ComponentDef<T> {