-
Notifications
You must be signed in to change notification settings - Fork 3.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
Remove isNative #964
Remove isNative #964
Conversation
Why we can remove isNative? Does draftjs do so too? |
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.
Hey @conorcussell, nice!
I added one comment, but I think more of the onBeforeInput
logic can be removed, which will further improve performance since that trigger fires a ton.
For testing, I think the best way to do it would be to use the Chrome Dev Tools performance stuff, and the "DEV: Large" (or similarly named) example that has tons of text, and just do a lot of typing individual characters while the performance metrics are collecting and then analyze. (You might even be able to feel the difference without analyzing to know immediately whether it slows things down a lot having removed it.)
Depending on what the outcome is, there might be a few new render code paths that need to be tweaked with the isNative
logic gone now. If you get it working towards that though I can clone this branch and do some tests of my own. Thanks for taking up this change!
src/plugins/core.js
Outdated
@@ -137,44 +134,9 @@ function Plugin(options = {}) { | |||
const nextText = next.startText | |||
const nextChars = nextText.getDecorations(decorators) |
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 nextChars
, nextText
(and probably others) are now unused so we don't need to compute them too? There might be a handful more lines of code we can remove here which will improve performance when checking further.
@kgdev I'm not sure we can remove it, but it's a hunch I wanted to investigate. One thing we do which Draft doesn't is that we memoize the Immutable.js objects, so many of their methods are very low cost to call for the second time if nothing has changed. I have no idea if it's something we can avoid doing, but it was worth an investigation since |
Thanks @ianstormtaylor I removed the rest of the code we don't need from that method. Will try and take a look at the perf impact in devtools and reply with my findings when I get a chance. |
Hey @conorcussell thanks again for kicking this off! I took your changes and added some more on #1088, so I'm going to close this now. Cheers! |
@ianstormtaylor I've removed isNative
I guess the library benchmarks don't give us much info on the performance changes here, any tips on checking the performance of this in the browser?
Also this appears to change the nature of at least one bug #938, instead of deleting the previous line, it does not allow you to add spaces on a wrapped line. I was working on a solution to this separately but still had some things to iron out.