xilem_web: Optimize modifiers (allocs mostly), and fix hydrating SVG elements #620
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.
With the risk of wasting time with micro-optimizations...
Honestly the diff bigger and more complex than I would like it to be for the effect that this change does, so I'm sorry to reviewers.
FWIW, I tested all the examples with the feature "hydration" disabled and enabled.
In effect this reduces the amount of allocs and the size of allocs of all the modifiers (since Vec allocs at least 4 elements) by:
start_idx
to avoid extra 4 bytes for just two booleans in each modifier, and also useu16
instead ofusize
to save another 4 bytes.updated_modifiers
allocations when building the element (with theCREATING
bitflag).Cow
was cloned, which for example with aString
as an attribute value resulted in an additional allocation).This minimally increases the wasm binary size (though I'm pretty sure in a constant fashion, roughly 500bytes compressed) in exchange for faster creation of elements and less memory usage (in the 10k js-framework-bench roughly 10% less memory usage, and 7-8% faster).
I've also noticed that all the kurbo SVG views weren't hydrated yet, which I think results in buggy behavior when using it e.g. in a
Templated
view, this is kind of drive-by fix (which I didn't want to separate because of additional work...)