Closed
Conversation
If we want to target an input write to a directive, we have to know the index at which its instance is stored. Technically we can already find this by looking through `TView.data`, but that'll require a linear lookup for each write which can get slow. These changes introduce the new `TNode.directiveToIndex` map which allows us to quickly find the index of a directive based on its definition, as well as any host directives that its might've brought in.
In order to mark a TNode as a component, we need to store the index of the component definition. Currently this happens in the logic that resolves host directives, because the component's host directives can move affect the index. These changes move the logic out into the directive initialization logic since it doesn't have much to do with host directives.
Currently the host directive logic disassembles and re-assembles the array of directive matches, in case there are host directives which in most cases produces an identical array. These changes add some logic so that we only need to allocate the additional memory if we actually need it.
…ectives Sets up the infrastructure that will allow to write only to a specific directive and its host directives as a base for future functionality. I've also renamed `setInputsForProperty` to be a bit more explicit that its sets all inputs.
pkozlowski-opensource
approved these changes
Feb 24, 2025
Contributor
|
@crisbeto Will there be some public api for checking if an input exists on a componentref ? I know that ComponentMirror has getInputs but this requires linear lookup too (and I am not shure if it works with host directives) |
Member
Author
Contributor
|
This PR was merged into the repository by commit 334d851. The changes were merged into the following branches: main, 19.2.x |
kirjs
pushed a commit
that referenced
this pull request
Feb 25, 2025
If we want to target an input write to a directive, we have to know the index at which its instance is stored. Technically we can already find this by looking through `TView.data`, but that'll require a linear lookup for each write which can get slow. These changes introduce the new `TNode.directiveToIndex` map which allows us to quickly find the index of a directive based on its definition, as well as any host directives that its might've brought in. PR Close #60075
kirjs
pushed a commit
that referenced
this pull request
Feb 25, 2025
#60075) In order to mark a TNode as a component, we need to store the index of the component definition. Currently this happens in the logic that resolves host directives, because the component's host directives can move affect the index. These changes move the logic out into the directive initialization logic since it doesn't have much to do with host directives. PR Close #60075
kirjs
pushed a commit
that referenced
this pull request
Feb 25, 2025
…ves (#60075) Currently the host directive logic disassembles and re-assembles the array of directive matches, in case there are host directives which in most cases produces an identical array. These changes add some logic so that we only need to allocate the additional memory if we actually need it. PR Close #60075
kirjs
pushed a commit
that referenced
this pull request
Feb 25, 2025
#60075) In order to mark a TNode as a component, we need to store the index of the component definition. Currently this happens in the logic that resolves host directives, because the component's host directives can move affect the index. These changes move the logic out into the directive initialization logic since it doesn't have much to do with host directives. PR Close #60075
kirjs
pushed a commit
that referenced
this pull request
Feb 25, 2025
…ves (#60075) Currently the host directive logic disassembles and re-assembles the array of directive matches, in case there are host directives which in most cases produces an identical array. These changes add some logic so that we only need to allocate the additional memory if we actually need it. PR Close #60075
|
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Includes a few more refactors around how we write to inputs.
refactor(core): track match index of directives
If we want to target an input write to a directive, we have to know the index at which its instance is stored. Technically we can already find this by looking through
TView.data, but that'll require a linear lookup for each write which can get slow.These changes introduce the new
TNode.directiveToIndexmap which allows us to quickly find the index of a directive based on its definition, as well as any host directives that its might've brought in.refactor(core): move component logic out of host directives resolution
In order to mark a TNode as a component, we need to store the index of the component definition. Currently this happens in the logic that resolves host directives, because the component's host directives can move affect the index.
These changes move the logic out into the directive initialization logic since it doesn't have much to do with host directives.
refactor(core): avoid memory allocations if there are no host directives
Currently the host directive logic disassembles and re-assembles the array of directive matches, in case there are host directives which in most cases produces an identical array.
These changes add some logic so that we only need to allocate the additional memory if we actually need it.
refactor(core): add infrastructure for setting inputs on specific directives
Sets up the infrastructure that will allow to write only to a specific directive and its host directives as a base for future functionality.
I've also renamed
setInputsForPropertyto be a bit more explicit that its sets all inputs.