File tree Expand file tree Collapse file tree 2 files changed +12
-24
lines changed
Expand file tree Collapse file tree 2 files changed +12
-24
lines changed Original file line number Diff line number Diff line change @@ -89,15 +89,13 @@ fn add_watch_by_event(
8989 return ;
9090 }
9191
92- let mut current = parent;
93- while let Some ( parent) = current. parent ( ) {
94- if let Some ( watch_mode) = watches. get ( parent)
92+ for ancestor in parent. ancestors ( ) . skip ( 1 ) {
93+ if let Some ( watch_mode) = watches. get ( ancestor)
9594 && watch_mode. recursive_mode == RecursiveMode :: Recursive
9695 {
9796 add_watches. push ( ( path. to_owned ( ) , true , is_file_without_hardlinks) ) ;
9897 return ;
9998 }
100- current = parent;
10199 }
102100}
103101
@@ -256,16 +254,11 @@ impl EventLoop {
256254 return true ;
257255 }
258256
259- let mut current = parent;
260- while let Some ( parent) = current. parent ( ) {
261- if let Some ( watch_mode) = watches. get ( parent)
262- && watch_mode. recursive_mode == RecursiveMode :: Recursive
263- {
264- return true ;
265- }
266- current = parent;
267- }
268- false
257+ parent. ancestors ( ) . skip ( 1 ) . any ( |ancestor| {
258+ watches
259+ . get ( ancestor)
260+ . is_some_and ( |watch_mode| watch_mode. recursive_mode == RecursiveMode :: Recursive )
261+ } )
269262 }
270263
271264 #[ expect( clippy:: too_many_lines) ]
Original file line number Diff line number Diff line change @@ -183,16 +183,11 @@ impl EventLoop {
183183 return true ;
184184 }
185185
186- let mut current = parent;
187- while let Some ( parent) = current. parent ( ) {
188- if let Some ( watch_mode) = watches. get ( parent)
189- && watch_mode. recursive_mode == RecursiveMode :: Recursive
190- {
191- return true ;
192- }
193- current = parent;
194- }
195- false
186+ parent. ancestors ( ) . skip ( 1 ) . any ( |ancestor| {
187+ watches
188+ . get ( ancestor)
189+ . is_some_and ( |watch_mode| watch_mode. recursive_mode == RecursiveMode :: Recursive )
190+ } )
196191 }
197192
198193 #[ expect( clippy:: too_many_lines) ]
You can’t perform that action at this time.
0 commit comments