Skip to content

Why use dynamic dispatch Children? #848

Closed Answered by gbj
ZihanType asked this question in Q&A
Discussion options

You must be logged in to vote

Fairly simple reason: in terms of performance the primary constraints on WASM are binary size and the actual DOM rendering process in the browser. Adding a generic bound to a component will cause the Rust compiler to monomorphize it, creating a completely new copy of the component code for each different generic. Because closures are always unique types, this would copy the size of the component code x the number of times you used it.

There's no difference in terms of the DOM rendering costs between the two, so there's no difference there. And the cost of dynamic dispatch is small relative to that larger rendering cost.

If you find yourself in a situation in which you think it's making a …

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@ZihanType
Comment options

@gbj
Comment options

gbj Apr 11, 2023
Maintainer

@ZihanType
Comment options

@gbj
Comment options

gbj Apr 11, 2023
Maintainer

@ZihanType
Comment options

Answer selected by ZihanType
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants