faster style-scope setPropertyValues#9083
Conversation
No need for so many for loops
NathanaelA
left a comment
There was a problem hiding this comment.
Have you benchmarked this against the current code, I'd be interested to know what savings (if any) you create with this refactor.
|
|
||
| let isCssExpressionInUse = false; | ||
|
|
||
| const oldProperties = this._appliedPropertyValues || {}; |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
| _onDynamicStateChangeHandler: () => void; | ||
| _appliedChangeMap: Readonly<ChangeMap<ViewBase>>; | ||
| _appliedPropertyValues: Readonly<Record<string, unknown>>; | ||
| _appliedPropertyValues: Record<string, unknown>; |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
There was a problem hiding this comment.
@NathanaelA then we should make it private instead ? the readonly think makes tsc not happy when i delete properties on oldProperties
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
|
|
||
| // Unset removed values | ||
| for (const property in oldProperties) { | ||
| if (!(property in newPropertyValues)) { |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
There was a problem hiding this comment.
@NathanaelA good catch. the issue is up. I mean in fact any value from newPropertyValues can be removed from oldProperties, right? So i should simply add the delete oldProperties[property]; for all values in the loop of newPropertyValues
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
|
@NathanaelA no benchmark no. Just globally faster as you loop through new props only once and loop through less old properties. |
This comment was marked as abuse.
This comment was marked as abuse.
@farfromrefug @NathanaelA even simpler: console.time('setPropertyValues')
this._setPropertyValues(...);
console.timeEnd('setPropertyValues')Will print the time it has taken :D |
|
@farfromrefug I've updated this PR with latest main and looks like just 4 tests are affected by these changes: Would you be able to peek sometime? We can queue this up to include in 8.4. It does appear that these changes will make the tests finish in faster time which leads me to believe there are some perf gains here. |
all tests are now passing
|
@NathanWalker all tests are now passing. Hope i got it all right. The issue was that css vars/exps need to be handled separately in the sense that all css vars must be evaluated before we can evaluate css expressions. I added a comment so we dont forget about it anymore. |
That Pr makes the style-scope
setPropertyValuesmuch faster. It tries not to do so many loops.The only real change is the fact that i dont freeze the
_appliedPropertyValuesobject anymore. I need that to go faster and as the object is not used outside of that function it does not seem to make a difference.Now do we have tests which would ensure that is not breaking anything?