@@ -242,7 +242,7 @@ export class YAMLSchemaService extends JSONSchemaService {
242242 }
243243
244244 const toWalk : JSONSchema [ ] = [ node ] ;
245- const seen : JSONSchema [ ] = [ ] ;
245+ const seen : Set < JSONSchema > = new Set ( ) ;
246246
247247 // eslint-disable-next-line @typescript-eslint/no-explicit-any
248248 const openPromises : Promise < any > [ ] = [ ] ;
@@ -278,7 +278,7 @@ export class YAMLSchemaService extends JSONSchemaService {
278278 }
279279 } ;
280280 const handleRef = ( next : JSONSchema ) : void => {
281- const seenRefs = [ ] ;
281+ const seenRefs = new Set ( ) ;
282282 while ( next . $ref ) {
283283 const ref = next . $ref ;
284284 const segments = ref . split ( '#' , 2 ) ;
@@ -289,9 +289,9 @@ export class YAMLSchemaService extends JSONSchemaService {
289289 openPromises . push ( resolveExternalLink ( next , segments [ 0 ] , segments [ 1 ] , parentSchemaURL , parentSchemaDependencies ) ) ;
290290 return ;
291291 } else {
292- if ( seenRefs . indexOf ( ref ) === - 1 ) {
292+ if ( ! seenRefs . has ( ref ) ) {
293293 merge ( next , parentSchema , parentSchemaURL , segments [ 1 ] ) ; // can set next.$ref again, use seenRefs to avoid circle
294- seenRefs . push ( ref ) ;
294+ seenRefs . add ( ref ) ;
295295 }
296296 }
297297 }
@@ -330,10 +330,10 @@ export class YAMLSchemaService extends JSONSchemaService {
330330
331331 while ( toWalk . length ) {
332332 const next = toWalk . pop ( ) ;
333- if ( seen . indexOf ( next ) >= 0 ) {
333+ if ( seen . has ( next ) ) {
334334 continue ;
335335 }
336- seen . push ( next ) ;
336+ seen . add ( next ) ;
337337 handleRef ( next ) ;
338338 }
339339 return Promise . all ( openPromises ) ;
0 commit comments