Skip to content
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

Faster repeated renderSVGDOM #51

Open
edemaine opened this issue Aug 7, 2019 · 0 comments
Open

Faster repeated renderSVGDOM #51

edemaine opened this issue Aug 7, 2019 · 0 comments

Comments

@edemaine
Copy link
Owner

edemaine commented Aug 7, 2019

Changing one cell, or inserting/deleting a row/column, currently requires completely rerendering the DOM via renderSVGDOM. Given that it's already a method of Drawing, it could cache the last version of symbols along with pointers to corresponding DOM objects and, if present (so rerendering the same drawing), look for optimizations to avoid hitting the DOM (if use links to the same object and has same x and y coordinates, do nothing). Simple version is to just check attributes and change only when needed. For bonus points, look at neighboring cells and optimize the case of shifting.

A lot of this can probably be done via Preact's render, possibly applied to each cell individually. (In particular, we may want to provide an API for rendering individual symbols as part of an entire diagram.) We'd need to keep track of the previous VDOM and let it do the diff. And we'd need to generate VDOM if the mapping returns a raw string.

We could also potentially avoid calling dynamic symbols in some cases, by detecting what neighbors they depend on, and only calling if that changes. (But this would prevent side effects...) See #80

I'm also not sure whether this should be an automatic optimization within Drawing or a specific Render instance that tracks the rendered symbols. (Currently this is all mushed together into Drawing. Maybe that's OK?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant