Performance improvement on parsing from html#790
Merged
Conversation
This reverts commit 36240e0.
1 task
daniloercoli
approved these changes
Mar 6, 2019
Contributor
daniloercoli
left a comment
There was a problem hiding this comment.
Demo app works fine.
Also tried all kind of tests attached to the project and they worked as expected.
mzorz
reviewed
Mar 6, 2019
mzorz
reviewed
Mar 7, 2019
Contributor
Author
|
Mario mentioned to me over Slack that he has no further review comments to add so, this is now 👍 to merge when CI passes. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR introduces a couple of speed of optimizations to address the slow start of the editor when the content is large. Relevant issue on wpandroid: wordpress-mobile/gutenberg-mobile#672
What's included:
parseHtml...method (parseHtmlForInspection). This one is forked fromfromHtml()and has these optimizations:a. Use of
SpannableStringinstead ofSpannableStringBuilder. We don't want the (slower)...Buildervariant here since we're not planning on modifying the text content of the String while processing it in this method. Some other functions were changed from expectingSpannableStringBuilderto expecting aSpannablesince they didn't actually needed the editabilitySpannableStringBuilder.b. Don't use the very expensive
addVisualNewlinesToBlockElements()since the parsed content is not going to be used for rendering it in the editor.c. Don't use
markBlockElementsAsParagraphs()since the spannable will not be used for editing at all so, no need for the PARAGRAPH_SPAN span behavior.d. Don't use
cleanupZWJ()as it doesn't mattertagStackto optimize the handling of end-tags inAztecTagHandler.kt. Up to now,AztecTagHandler.end()was usinggetLast()which scans the spans to find the most recent "open" tag, but that can be sped up since we know about the nested nature of the html tags. So, a LIFO tracks the opening/closings of the tags and we normally expect the most recent open tag to be exactly at the top of the stack.Test A
Test B
Review
@[USER_NAME]