Skip to content
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

Leverage Immer diffing #132

Open
arximboldi opened this issue Feb 8, 2022 · 0 comments
Open

Leverage Immer diffing #132

arximboldi opened this issue Feb 8, 2022 · 0 comments

Comments

@arximboldi
Copy link
Owner

Consider a scenario:

lager::reader<immer::map<K, V>> parent = ...;
lager::reader<V> child1 = paren[k0];
lager::reader<V> child2 = paren[k1];
...
lager::reader<V> childN = parent[kN];

At the moment, whenever any value changes inside the map, even if it is only the element pointed at by one of the children, there will be N comparisons performed when propagating the data to the children (each child has to check if their element did change).

However, Immer now supports strucutural-sharing aware diffing.

This means we can implement an optimization in Lager such that it detects this particular scenario and uses immer::diff() to detect which children did change and propagate changes directly to those, ignoring the children that did not change, potentially turning O(N) into O(1) for most common UI patterns!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant