-
Notifications
You must be signed in to change notification settings - Fork 170
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
[BUG] built is duplicating "current" in the array for every child element #186
Comments
@LionsAd finally getting back to this - any chance you're seeing a circular reference in JS but the PHP port happens to clone the Array making it grow? 'm still digging into around, but on master it appears to be a shared array reference that gets reset. |
Oh - that might very well be. I saw it growing in the JS array as well, but did not check memory usage when memo‘ed. I will double check that memory usage actually grows. Thanks for checking that. |
No problem! Sorry I didn't have a definitive answer - I still need to refamiliarize myself with the current codebase 😅 |
This is intentional. We use Therefore each Tangentially related: After the whole tree has been parsed the "stack" functionality isn't used anymore, so in |
To reproduce in JS console with built.mjs pasted in:
Expected output:
APPEND_CHILD, TAG_SET, PROP_SET, PROP_SET, CHILD_RECURSIVE
Real output:
This is from my PHP port of preact (just an experiment), but it also happens with preact master in Javascript.
I think when recursing into the children, the data should be stored in a stack variable and not in current[0].
While for traversing that's not a problem, it increases the size of current dramatically and this - unless cleaned up - is what is cached, which is also not ideal as the sparse data should be as small as possible obviously.
To fix:
The fix is trivial also:
htm/src/build.mjs
Line 262 in ed1c620
be replaced with:
should be all that is needed. Also could fix the double usage of the name
mode
at the same time. Likelytmp
orcurrent_child
or such might be better.The text was updated successfully, but these errors were encountered: