-
-
Notifications
You must be signed in to change notification settings - Fork 924
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
[refactor] Refactoring of hyperscript.js and render.js, including performance improvements #2983
Conversation
… render.js with another workaround in hyperscript.js The input[type] inspection at the beginning of setAttr() was called for each attribute. This had a negative impact on performance. The new workaround in execSelector() controls the order of setting attributes by reordering the keys in attrs.
The isFileInput is needed only when key is "value", so moving the logic into setAttr() would not increase time of calculation. Also, the code outlook improves a bit, of course.
The polyfill doesn't support multiple source objects, and almost all browsers now natively support Object.assign().
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.
One minor nit, then it's got my approval.
(This will cause some merge conflicts for my #2982, but it wouldn't be the first time I rebuilt that PR.)
util/assign.js
Outdated
if (hasOwn.call(source, key)) target[key] = source[key] | ||
} | ||
} | ||
module.exports = Object.assign |
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.
Could you just drop this module entirely and use Object.assign
directly in the places that use it?
Shouldn't impact performance, but will provide a small bundle size win and it's one less source file to worry about.
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.
OK, I removed the module.
@dead-claudia |
Oops, meant to squash that, but was also debugging Refined GitHub at the same time. 🙃 |
Refactor hyperscript.js and render.js. In particular, the replacement of fix #2622 appears to have significantly improved the performance regression.
Description
This change is a refactoring aimed at improving code outlook and performance.
results of `npm run perf`
before (v2.2.8)
after ("rerender same tree" is improved)
cf. v2.0.4 (by backported test-perf.js and m.censor)
As shown above,
npm run perf
is improved, especially for "rerender same tree".I have also run test-perf.js in a real browser to see the performance improvement.
(If necessary, I would like to measure and tabulate performance later.)
Motivation and Context
As for performance, it is sufficiently sophisticated at v2.0.4. However, subsequent bug fixes and enhancements seem to have caused some performance regression. I measured the performance of v2.0.4 and later versions with
npm run perf
and found that 7c7d76d of #2578 has a negative impact on performance.The commit 7c7d76d fixes #2622 by changing setAttr(s), but I noticed that it can be resolved by hyperscript(execSelector) instead of setAttr(s).
How Has This Been Tested?
npm run test
Types of changes
Checklist