Skip to content
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

fix(html): Reduce calls to unescape_characters which is slow #52

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

James-LG
Copy link
Owner

@James-LG James-LG commented Sep 2, 2024

The unescape_characters method is slow, so the places it is called have been reduced.

Ideally it's performance would be improved, but the html module is in the process of being completely rewritten (#51) so this is just a stop-gap.

The `unescape_characters` method is slow, so the places it is called have been reduced.

Ideally it's performance would be improved, but the html module is in the process of being completely rewritten so this is just a stop-gap.
@@ -141,12 +143,20 @@ pub struct HtmlText {
impl HtmlText {
/// Creates a new [HtmlText] from the given string.
pub fn from_str(value: &str) -> HtmlText {
let text = unescape_characters(value);
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unescape_characters used to be called when creating a new HtmlText. Now it is only called when getting the display text for a given HtmlText, so if that HtmlText never needs to display its text, the slow method will not be called.

@James-LG James-LG mentioned this pull request Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant