@@ -240,7 +240,7 @@ export const trueAffected = async ({
240240 }
241241
242242 const affectedPackages = new Set < string > ( changedIncludedFilesPackages ) ;
243- const visitedIdentifiers = new Map < string , string [ ] > ( ) ;
243+ const visitedIdentifiers = new Map < string , Set < string > > ( ) ;
244244
245245 const findReferencesLibs = ( node : Node < ts . Node > ) => {
246246 const rootNode = findRootNode ( node ) ;
@@ -269,7 +269,6 @@ export const trueAffected = async ({
269269 /* istanbul ignore next */
270270 if ( identifier == null ) return ;
271271
272- const refs = identifier . findReferencesAsNodes ( ) ;
273272 const identifierName = identifier . getText ( ) ;
274273 const path = rootNode . getSourceFile ( ) . getFilePath ( ) ;
275274
@@ -278,22 +277,27 @@ export const trueAffected = async ({
278277 ) ;
279278
280279 if ( identifierName && path ) {
281- const visited = visitedIdentifiers . get ( path ) ?? [ ] ;
282- if ( visited . includes ( identifierName ) ) {
280+ if ( ! visitedIdentifiers . has ( path ) ) {
281+ visitedIdentifiers . set ( path , new Set ( ) ) ;
282+ }
283+ const visited = visitedIdentifiers . get ( path ) ! ;
284+ if ( visited . has ( identifierName ) ) {
283285 logger . debug (
284286 `Already visited ${ chalk . bold ( identifierName ) } in ${ chalk . bold ( path ) } `
285287 ) ;
286288
287289 return ;
288290 }
289291
290- visitedIdentifiers . set ( path , [ ... visited , identifierName ] ) ;
292+ visited . add ( identifierName ) ;
291293
292294 logger . debug (
293295 `Visiting ${ chalk . bold ( identifierName ) } in ${ chalk . bold ( path ) } `
294296 ) ;
295297 }
296298
299+ const refs = identifier . findReferencesAsNodes ( ) ;
300+
297301 refs . forEach ( ( node ) => {
298302 const sourceFile = node . getSourceFile ( ) ;
299303 const pkg = getPackageNameByPath ( sourceFile . getFilePath ( ) , projects ) ;
0 commit comments