In the most simple case, we need to compare all properties of state A with B. If there is no change no need to redraw. It should be done on every virtual part of the object too. (e.g. slider knob also goes to pressed state).
It’s about 100 queries per state per part. E.g. 100 x 2 states x 2 parts = 400 queries.
However, some optimization can be applied:
- break on the first difference: if there is a change in the styles probably we will quickly find it if the most relevant properties are checked first.
- exclude not visible properties: e.g. if border_widht is zero, border_color is irrelevant.
So we can add a well-optimized function to tests the difference between 2 states. If it says there is no difference between the 2 states just set the state and return without refresh.
What do you think?