Omnistac / zedux

:zap: A Molecular State Engine for React
https://Omnistac.github.io/zedux/
MIT License
344 stars 7 forks source link

feat(atoms): improve graph perf by removing unnecessary `Object.keys()` calls #52

Closed bowheart closed 1 year ago

bowheart commented 1 year ago

Description

There are several places where we don't have to call Object.keys(). In some stress tests, these can be called a lot, resulting in lots of overhead.

Remove 2 of these Object.keys() calls in the graph - when scheduling and unscheduling node destruction. Instead add a refCount counter that we manually keep in sync with the dependents count.