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
refactor(ivy): access component def through tData #22771
Conversation
You can preview 13cfafa at https://pr22771-13cfafa.ngbuilds.io/. |
You can preview e95c8cd at https://pr22771-e95c8cd.ngbuilds.io/. |
You can preview b9ea9c8 at https://pr22771-b9ea9c8.ngbuilds.io/. |
const directiveType = directiveTypes[i]; | ||
const directiveDef = directiveType.ngDirectiveDef; | ||
const directiveDef = currentView.tView.firstTemplatePass ? directiveType.ngDirectiveDef : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same issue here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the same deal - the directiveDef is passed through to directiveCreate, which saves it on tData.
let hostComponentDef: ComponentDef<any>|null = null; | ||
let name = nameOrComponentType as string; | ||
if (isHostElement) { | ||
hostComponentDef = currentView.tView.firstTemplatePass ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not look right to me.
- if
firstTemplatePass
is true than we do megamorphic read onngComponentDef
. However I don't see the value being saved. - if
firstTemplatePass
is false than we read fromtData
which is right, but how did thetData
get hold of thengComponentDef
Was there a separate read some place else?
What I am getting at is that I think we read ngComponentDef
more often than we should. (We should do it exactly once) but the fact that we are not saving the value and than it is in tData
tells me that there must be a second read someplace else which places it in tData
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The componentDef is passed through to directiveCreate
, which saves it on tData
. This is the only read site. directiveCreate
uses the def that is passed to it directly and does not do a read.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the confusion
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Small PR to remove unnecessary megamorphic property accesses when creating directives and components. Now we just incur the cost on the first template pass.