Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
Optimizations for mapped style properties #2239
This PR includes two proposed performance optimizations to styling, specifically for mapped properties.
maxkfranz left a comment
Thanks for the PR. I'm on vacation, but I wanted to respond to this within a reasonable time.
I agree with (1), but I don't see how (2) would provide a benefit over having the library consumer memoizing his function. Allowing the consumer to control caching and copying probably allows for greater control of performance. With the implementation of (2) right now, we have copying overhead that does not exist for
And then I was on vacation and failed to respond in a reasonable time - sorry for the delay!
Thanks much for the in depth feedback! I added a couple in-line comments, but also wanted to address your more general question about (2) vs. memoize. I think they both contribute to improved performance but solve different problems.
Memoize would definitely speed up the actual computation of the property value via its caching functionality. The performance gains from (2) are not from caching the previous value (which is just a means to compare it to the new value), but from from bypassing the
That being said, I do recognize the added overhead of copying (if it ends up being necessary). But (2) would still provide performance gains, even for memoized style properties, since they're impacting different parts of the process.
Does that make any more sense than before?
That helps to clarify things. As described in the code comment, if possible, I'd like to see all the logic within