11use std:: {
2- cell:: RefCell ,
32 hash:: { Hash , Hasher } ,
43 mem,
54 rc:: Rc ,
65} ;
76
87use oxc:: allocator;
9- use rustc_hash:: FxHashSet ;
108
119use crate :: {
1210 analyzer:: { Analyzer , rw_tracking:: ReadWriteTarget } ,
@@ -28,7 +26,6 @@ pub struct ExhaustiveData<'a> {
2826pub struct ExhaustiveCallback < ' a > {
2927 pub handler : Rc < dyn Fn ( & mut Analyzer < ' a > ) -> Entity < ' a > + ' a > ,
3028 pub drain : bool ,
31- pub triggered : Rc < RefCell < FxHashSet < ReadWriteTarget < ' a > > > > ,
3229}
3330impl PartialEq for ExhaustiveCallback < ' _ > {
3431 fn eq ( & self , other : & Self ) -> bool {
@@ -136,11 +133,11 @@ impl<'a> Analyzer<'a> {
136133 deps : allocator:: HashSet < ReadWriteTarget < ' a > > ,
137134 ) {
138135 for id in deps {
139- self . exhaustive_callbacks . entry ( id ) . or_default ( ) . insert ( ExhaustiveCallback {
140- handler : handler . clone ( ) ,
141- drain ,
142- triggered : Default :: default ( ) ,
143- } ) ;
136+ self
137+ . exhaustive_callbacks
138+ . entry ( id )
139+ . or_default ( )
140+ . insert ( ExhaustiveCallback { handler : handler . clone ( ) , drain } ) ;
144141 }
145142 }
146143
@@ -150,10 +147,7 @@ impl<'a> Analyzer<'a> {
150147 if let Some ( callbacks) = self . exhaustive_callbacks . get_mut ( & id)
151148 && !callbacks. is_empty ( )
152149 {
153- for callback in callbacks. drain ( ) {
154- callback. triggered . borrow_mut ( ) . insert ( id) ;
155- self . pending_callbacks . insert ( callback) ;
156- }
150+ self . pending_deps . extend ( callbacks. drain ( ) ) ;
157151 found = true ;
158152 }
159153 } ;
@@ -163,17 +157,15 @@ impl<'a> Analyzer<'a> {
163157 }
164158
165159 pub fn call_exhaustive_callbacks ( & mut self ) -> bool {
166- if self . pending_callbacks . is_empty ( ) {
160+ if self . pending_deps . is_empty ( ) {
167161 return false ;
168162 }
169163 let old_try_catch_depth = self . scoping . try_catch_depth . take ( ) ;
170164 loop {
171- for callback in mem:: take ( & mut self . pending_callbacks ) {
172- self . active_callback_triggers . extend ( & callback. triggered . borrow ( ) ) ;
173- self . exec_exhaustively ( "dep" , callback. drain , true , callback. handler . clone ( ) ) ;
174- self . active_callback_triggers . unextend ( & callback. triggered . borrow ( ) ) ;
165+ for ExhaustiveCallback { drain, handler } in mem:: take ( & mut self . pending_deps ) {
166+ self . exec_exhaustively ( "dep" , drain, true , handler. clone ( ) ) ;
175167 }
176- if self . pending_callbacks . is_empty ( ) {
168+ if self . pending_deps . is_empty ( ) {
177169 self . scoping . try_catch_depth = old_try_catch_depth;
178170 return true ;
179171 }
0 commit comments