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

check whether style needs a suffix with a set and remove debug casting #286

Merged
merged 9 commits into from
Mar 22, 2023

Conversation

JoviDeCroock
Copy link
Member

@JoviDeCroock JoviDeCroock commented Mar 18, 2023

In Preact >= 10.13.0 we fixed the debug casting, this removes this check as we're doing a major either way.

This also optimises style casting by using a Set, removing the need for the cache and thus saving some memory

@changeset-bot
Copy link

changeset-bot bot commented Mar 18, 2023

🦋 Changeset detected

Latest commit: 3f21e88

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 Major

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

@JoviDeCroock JoviDeCroock changed the title check whether style needs a suffix with a set check whether style needs a suffix with a set and remove debug casting Mar 19, 2023
src/index.js Outdated Show resolved Hide resolved
@@ -145,15 +145,6 @@ function _renderToString(vnode, context, isSvgMode, selectValue, parent) {
rendered =
rendered +
_renderToString(child, context, isSvgMode, selectValue, parent);

if (
Copy link
Member Author

Choose a reason for hiding this comment

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

We fixed this in 10.13.0, I honestly think we shouldn't put a preact/debug fix in our hot path

Copy link
Member

Choose a reason for hiding this comment

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

I'm a bit out of the loop. Which issue in preact/debug did this section work around?

Copy link
Member Author

@JoviDeCroock JoviDeCroock Mar 20, 2023

Choose a reason for hiding this comment

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

This one #257 this was fixed in Preact itself with preactjs/preact#3801

Copy link
Member

Choose a reason for hiding this comment

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

Ohh right!

@@ -338,6 +329,8 @@ function _renderToString(vnode, context, isSvgMode, selectValue, parent) {
}

if (UNSAFE_NAME.test(type)) {
// this seems to performs a lot better than throwing
// return '<!-- -->';
Copy link
Member Author

Choose a reason for hiding this comment

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

This could give us an additional 5% boost

Copy link
Member

Choose a reason for hiding this comment

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

I really like that idea!

@@ -1313,7 +1313,7 @@ describe('render', () => {
);
}

expect(render(<App />)).to.equal('<div><p>P481</p><p>P476951</p></div>');
expect(render(<App />)).to.equal('<div><p>P0-0</p><p>P0-1</p></div>');
Copy link
Member Author

Choose a reason for hiding this comment

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

use-id handling seems to be different in Preact 10.13

@JoviDeCroock JoviDeCroock force-pushed the optimize-style-suffix branch from b5a749e to fb3a5e9 Compare March 20, 2023 11:36
Copy link
Member

@marvinhagemeister marvinhagemeister left a comment

Choose a reason for hiding this comment

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

Great work as always!

Copy link
Member

@andrewiggins andrewiggins left a comment

Choose a reason for hiding this comment

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

🎉 Super stoked by all this perf work on RTS!

if (
typeof val === 'number' &&
// Exclude custom-attributes
!name.startsWith('--') &&
Copy link
Member

Choose a reason for hiding this comment

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

Is this check doing the same thing as line 98, i.e. are they both trying to check for custom properties? Do we get any perf benefit by consolidating them?

@JoviDeCroock JoviDeCroock merged commit 7a8b590 into master Mar 22, 2023
@JoviDeCroock JoviDeCroock deleted the optimize-style-suffix branch March 22, 2023 07:11
@github-actions github-actions bot mentioned this pull request Mar 22, 2023
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