-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Flatten children array as it is diffed #1716
Conversation
If anyone has the time and setup, would love to know if this PR moves the perf at all |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good, in my mind this feels slower because of the function allocation but I think that’s because I think about the classic engines. Should be tested, I’ll see if I can find the big jsperf benchmark on my laptop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So good 👍 💯 Skipping a whole iteration should be faster in theory but I haven't made any tests to get some numbers. @developit maybe you got some benches ready when you suggested the change on slack? 🙂
Hey @andrewiggins took a stab at it and tried to resolve the conflicts 🕺 If something it's not right, please let me know. |
ee8fd52
to
480b1f0
Compare
*/ | ||
export function toChildArray(children, flattened, map, keepHoles) { | ||
export function toChildArray(children, callback, flattened) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC the first two args here are used externally. Maybe worth changing to toChildArray(children, flattened, callback)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that change was made for golfing purposes in children.js
. There it's used without the flattened
argument. Either way we've only advertised the first arg so far in our types and elsewhere. So I think it's fine to swap them like it's done here.
Instead of passing over the newVNode's children array twice (once in
toChildArray
to flatten it, and once again indiffChildren
to diff the children), we now pass over the children once, diffing the children and flattening the list as we go.Total change:
+6 B (22e0fba)-4 B (ffc1713)