Skip to content

Speed up fillStyle= and strokeStyle= #1617

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

Merged
merged 2 commits into from
Jul 17, 2020

Conversation

zbjornson
Copy link
Collaborator

I was confused why I was seeing CanvasPattern show up in CPU profiles when we never use them. Turns out it's from these setters.

Roughly 2x performance improvement.

  • Don't create extra Local<FunctionTemplate> handles

  • Don't create any Local<FunctionTemplate> handles if the value is a string

  • Have you updated CHANGELOG.md?

@zbjornson zbjornson force-pushed the zb/faster-setters branch from 6447a72 to b055d69 Compare July 7, 2020 01:57
zbjornson added 2 commits July 6, 2020 19:31
Roughly 2x performance improvement.
- Don't create extra Local<FunctionTemplate> handles
- Don't create any Local<FunctionTemplate> handles if the value is a string

I have no idea what that test case was doing.
> The style can be either a string containing a CSS color, or a CanvasGradient or CanvasPattern object. Invalid values are ignored
@zbjornson zbjornson force-pushed the zb/faster-setters branch from b055d69 to 90bbd5d Compare July 7, 2020 02:31
@@ -1756,7 +1756,7 @@ describe('Canvas', function () {
var canvas = createCanvas(2, 2);
var ctx = canvas.getContext('2d');

ctx.fillStyle = ['#808080'];
ctx.fillStyle = '#808080';
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have no idea what this test was supposed to be doing...

Copy link
Collaborator

@LinusU LinusU left a comment

Choose a reason for hiding this comment

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

Nice 👏 👏

@zbjornson zbjornson merged commit bf5126b into Automattic:master Jul 17, 2020
@zbjornson zbjornson deleted the zb/faster-setters branch July 17, 2020 02:15
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