Performance improvements for colors #8355
Open
+114
−50
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Addresses #8316
Changes:
defaultStringValue: if present, just return that instead of going through colorjs. That gives us an opportunity to add some custom faster logic in key places.CanvasRenderingContext2D, so if you create a color that way, we can use the string directly as thedefaultStringValue_colorobject to be lazy: it only gets created if we need it, e.g. if we're converting between color modes. This saves a little time in less complex cases.Mapwhere we can quickly see itssizeand remove items if need be.Live: https://editor.p5js.org/davepagurek/sketches/UG6fwp2hc
In this test sketch, I get 40fps where in 2.1.2 I get 12fps. Note that in 1.11.1, it still achieves >50fps though. But it's an improvement.
PR Checklist
npm run lintpasses