-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
chore: improve performance of DOM traversal operations #12863
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
Conversation
🦋 Changeset detectedLatest commit: 39acd8d The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@@ -116,7 +116,7 @@ export function each(node, flags, get_collection, get_key, render_fn, fallback_f | |||
var parent_node = /** @type {Element} */ (node); | |||
|
|||
anchor = hydrating | |||
? set_hydrate_node(/** @type {Comment | Text} */ (parent_node.firstChild)) | |||
? set_hydrate_node(/** @type {Comment | Text} */ (get_first_child(parent_node))) |
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.
In #12863 (comment) I was referring to these calls too. Isn't parent_node.firstChild
preferable? Surely get_first_child
is polymorphic (megamorphic?), given we call it with different node types
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.
Interestingly, we used to have this optimisation but we removed them as we thought they didn't improve performance. It turns out that we were wrong and they actually do and it was likely that Chrome 125 was had a regression. Specifically we can avoid a nasty V8 deopt on one of the most expensive hot paths in the codebase.
Megamorphic deopt
Monomorphic, no deopts