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

[perf] Improve string encoding performance by ~50% #228

Merged
merged 4 commits into from
Jul 21, 2022

Conversation

developit
Copy link
Member

@developit developit commented Jul 21, 2022

Entity encoding is a large portion of time spent, since we encode all attribute values and text nodes.
This switches encoding from multiple regular expressions to a linear forward scan.

In the benchmark below, the previous algorithm is the second bar ("replace"), and the new algorithm is the last bar ("scanSegments 2"):

Screen Shot 2022-07-20 at 9 46 45 PM

Note: This doesn't show up in our two benchmarks here, because there are no entities present in the text or attributes in those benchmarks.

Entity encoding is a large portion of time spent, since we encode all attribute values and text nodes.
This switches encoding from multiple regular expressions to a linear forward scan.
@changeset-bot
Copy link

changeset-bot bot commented Jul 21, 2022

🦋 Changeset detected

Latest commit: e4fe799

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
preact-render-to-string Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

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.

3 participants