@@ -242,7 +242,7 @@ export class YAMLSchemaService extends JSONSchemaService {
242
242
}
243
243
244
244
const toWalk : JSONSchema [ ] = [ node ] ;
245
- const seen : JSONSchema [ ] = [ ] ;
245
+ const seen : Set < JSONSchema > = new Set ( ) ;
246
246
247
247
// eslint-disable-next-line @typescript-eslint/no-explicit-any
248
248
const openPromises : Promise < any > [ ] = [ ] ;
@@ -278,7 +278,7 @@ export class YAMLSchemaService extends JSONSchemaService {
278
278
}
279
279
} ;
280
280
const handleRef = ( next : JSONSchema ) : void => {
281
- const seenRefs = [ ] ;
281
+ const seenRefs = new Set ( ) ;
282
282
while ( next . $ref ) {
283
283
const ref = next . $ref ;
284
284
const segments = ref . split ( '#' , 2 ) ;
@@ -289,9 +289,9 @@ export class YAMLSchemaService extends JSONSchemaService {
289
289
openPromises . push ( resolveExternalLink ( next , segments [ 0 ] , segments [ 1 ] , parentSchemaURL , parentSchemaDependencies ) ) ;
290
290
return ;
291
291
} else {
292
- if ( seenRefs . indexOf ( ref ) === - 1 ) {
292
+ if ( ! seenRefs . has ( ref ) ) {
293
293
merge ( next , parentSchema , parentSchemaURL , segments [ 1 ] ) ; // can set next.$ref again, use seenRefs to avoid circle
294
- seenRefs . push ( ref ) ;
294
+ seenRefs . add ( ref ) ;
295
295
}
296
296
}
297
297
}
@@ -330,10 +330,10 @@ export class YAMLSchemaService extends JSONSchemaService {
330
330
331
331
while ( toWalk . length ) {
332
332
const next = toWalk . pop ( ) ;
333
- if ( seen . indexOf ( next ) >= 0 ) {
333
+ if ( seen . has ( next ) ) {
334
334
continue ;
335
335
}
336
- seen . push ( next ) ;
336
+ seen . add ( next ) ;
337
337
handleRef ( next ) ;
338
338
}
339
339
return Promise . all ( openPromises ) ;
0 commit comments