File tree Expand file tree Collapse file tree 2 files changed +24
-9
lines changed
packages/atom/src/internal Expand file tree Collapse file tree 2 files changed +24
-9
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " @effect-atom/atom " : patch
3+ " @effect-atom/atom-livestore " : patch
4+ " @effect-atom/atom-react " : patch
5+ " @effect-atom/atom-vue " : patch
6+ ---
7+
8+ optimize internal active children check
Original file line number Diff line number Diff line change @@ -477,16 +477,23 @@ function childrenAreActive(children: Array<Node<any>>): boolean {
477477 if ( children . length === 0 ) {
478478 return false
479479 }
480- for ( let i = 0 , len = children . length ; i < len ; i ++ ) {
481- const child = children [ i ]
482- if ( ! child . atom . lazy || child . listeners . length > 0 ) {
483- return true
484- }
485- }
486- for ( let i = 0 , len = children . length ; i < len ; i ++ ) {
487- if ( childrenAreActive ( children [ i ] . children ) ) {
488- return true
480+ let current : Array < Node < any > > | undefined = children
481+ let stack : Array < Array < Node < any > > > | undefined
482+ let stackIndex = 0
483+ while ( current !== undefined ) {
484+ for ( let i = 0 , len = current . length ; i < len ; i ++ ) {
485+ const child = current [ i ]
486+ if ( ! child . atom . lazy || child . listeners . length > 0 ) {
487+ return true
488+ } else if ( child . children . length > 0 ) {
489+ if ( stack === undefined ) {
490+ stack = [ child . children ]
491+ } else {
492+ stack . push ( child . children )
493+ }
494+ }
489495 }
496+ current = stack ?. [ stackIndex ++ ]
490497 }
491498 return false
492499}
You can’t perform that action at this time.
0 commit comments