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

Refactor StyleSheet.create to improve performance #299

Merged
merged 4 commits into from Feb 16, 2018
Merged

Refactor StyleSheet.create to improve performance #299

merged 4 commits into from Feb 16, 2018

Conversation

lencioni
Copy link
Collaborator

This PR aims to improve performance of this hot path by reducing the number of function calls and object creation.

Removing this abstraction that was only used in one place simplifies the
code a little and theoretically should improve performance by avoiding
some extra function calls and object creation. I say theoretically
because my rudimentary profiling is pretty inconclusive. It is possible
that my benchmark scenario is non-representative, the browser is
optimizing this away anyway. In either case, this seems like a small
improvement.
Instead of checking this on every iteration, we can just set it when the
module first runs, and then switch it out when minify() is called. This
should keep the hot path as fast as possible.
I forgot to do this in my rollup PR.
@lencioni
Copy link
Collaborator Author

FYI @Soreine I ended up refactoring your minify check a little here. Care to review this PR?

Copy link
Contributor

@Soreine Soreine left a comment

Choose a reason for hiding this comment

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

It looks better indeed.

When, because of performance issues, some piece of code is unnatural or surprising, but it should not be changed without thought, it can be worth adding a comment.
I personally use this format: // PERF: Reasons why the code is that way...

@lencioni
Copy link
Collaborator Author

Thanks for the suggestion! I thought it seemed fairly natural, but I guess it doesn't hurt to drop in a few comments. I'll follow up with that.

@lencioni lencioni merged commit 2e15da8 into master Feb 16, 2018
@Soreine
Copy link
Contributor

Soreine commented Feb 16, 2018 via email

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.

None yet

2 participants