-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Inefficient teardown code? #99
Comments
Yes, definitely – we should collect all those statements together. Shouldn't be that hard – would just need to have one block of non-detach teardown statements (removing event listeners, that sort of thing) and one block of detach statements. The generated code currently bears all the hallmarks of someone who doesn't yet fully understand the problem space just trying to get his damn code to work 😀 I'd kind of hoped that minifiers would be able to handle these cases smartly, but I'm not sure that's the case. So yeah, it's on us. |
@Rich-Harris Would splitting // teardownStatements: []
teardownStatements: { onDetach: [], always: [] } I could work on that. 😊 |
basically yeah! though probably clearer if we do it this way instead: + detachStatements: [],
teardownStatements: []
🤘 |
The compiled code seems to be not efficient in the teardown function. It keeps repeating the same if (detach) check for each node. If you have 100 nodes in a component, then you'll end up with 100 if (detach) checks instead of just one.
The compiled code below was taken from Hello World sample at https://svelte.technology/repl/?gist=0ed5146aa22c28410dfcff2050f3d2f8
The text was updated successfully, but these errors were encountered: