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

use value class to improve StyledComponent constructor time #512

Merged
merged 2 commits into from
Feb 12, 2024

Conversation

wagyourtail
Copy link
Contributor

@wagyourtail wagyourtail commented Feb 12, 2024

I noticed while profiling that it was taking a significant amount of time to construct components on one of my projects with a very large dom.

by very large I mean
image

this improvement is achived by making the delegate for refreshOnUpdate a value class, and directly supplying the delegate when there is no initial value. therefore allowing for less class construction and storing of the delegate classes.

before:
image
image

after:
image
image

profiling was done on Chrome on my linux desktop.

@wagyourtail
Copy link
Contributor Author

wagyourtail commented Feb 12, 2024

second commit fixed that I missed value on Style's refresh delegate.
image

I haven't changed my codebase otherwise, idk why the profiler is missing StyledComponent's inner constructor on the After in the original after screenshot

@rjaros rjaros merged commit 89017a9 into rjaros:master Feb 12, 2024
@rjaros
Copy link
Owner

rjaros commented Feb 12, 2024

Great improvement! Thank you!

@wagyourtail wagyourtail deleted the fix/faster-constructor branch February 12, 2024 21:29
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.

2 participants