-
Notifications
You must be signed in to change notification settings - Fork 4.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
Pasting: Fix performance regression due to removeWindowsFragments #41907
Conversation
Size Change: +36 B (0%) Total Size: 1.25 MB
ℹ️ View Unchanged
|
The failing Static Analysis checks should be resolved now - #41916. |
Fixes #41826. removeWindowsFragments was running two String#replace with regular expressions made computationally expensive due to the use of `.*` and the `s / dotAll` flag, resulting in severe performance degradations when handling larger strings of HTML. The solution is to manually trim the strings via a combination of String#indexOf and String#substring.
e04f76f
to
8826fdc
Compare
Thanks! Rebased. |
Thank you. TIL something important 🙇♂️ |
Thanks for the fix! It might be worth commenting within the function that this is a hot path and can affect pasting performance for all, hence the importance of being extra lean in operations. |
…1907) * Pasting: Fix performance regression due to removeWindowsFragments Fixes #41826. removeWindowsFragments was running two String#replace with regular expressions made computationally expensive due to the use of `.*` and the `s / dotAll` flag, resulting in severe performance degradations when handling larger strings of HTML. The solution is to manually trim the strings via a combination of String#indexOf and String#substring. * removeWindowsFragments: bail early if no StartFragment found
I just cherry-picked this PR to the wp/6.0 branch to get it included in the next release: ae46fef |
Fixes #41826.
Alternative to #41881.
In RichText's
usePasteHandler
,removeWindowsFragments
was running twoString#replace
with regular expressions made computationally expensive due to the use of.*
and thes / dotAll
flag, resulting in severe performance degradations when handling larger strings of HTML.The solution is to manually trim the strings via a combination of
String#indexOf
andString#substring
.Testing Instructions
See parent issue, #41826, confirm that pasting is now reasonably fast (~ 1s) for the attached sample.