@@ -1349,24 +1349,16 @@ function initSearch(rawSearchIndex) {
1349
1349
continue ;
1350
1350
}
1351
1351
if ( fnType . id < 0 && queryElem . id < 0 ) {
1352
- if ( mgens === null ) {
1353
- mgens = new Map ( ) ;
1352
+ if ( mgens && mgens . has ( fnType . id ) &&
1353
+ mgens . get ( fnType . id ) !== queryElem . id ) {
1354
+ continue ;
1354
1355
}
1355
- const alreadyAssigned = mgens . has ( fnType . id ) ;
1356
- if ( alreadyAssigned ) {
1357
- if ( mgens . get ( fnType . id ) !== queryElem . id ) {
1358
- continue ;
1359
- }
1360
- } else {
1361
- mgens . set ( fnType . id , queryElem . id ) ;
1362
- }
1363
- if ( ! solutionCb || solutionCb ( mgens ) ) {
1356
+ const mgensScratch = new Map ( mgens ) ;
1357
+ mgensScratch . set ( fnType . id , queryElem . id ) ;
1358
+ if ( ! solutionCb || solutionCb ( mgensScratch ) ) {
1364
1359
return true ;
1365
1360
}
1366
- if ( ! alreadyAssigned ) {
1367
- mgens . delete ( fnType . id ) ;
1368
- }
1369
- } else if ( ! solutionCb || solutionCb ( mgens ) ) {
1361
+ } else if ( ! solutionCb || solutionCb ( mgens ? new Map ( mgens ) : null ) ) {
1370
1362
// unifyFunctionTypeIsMatchCandidate already checks that ids match
1371
1363
return true ;
1372
1364
}
@@ -1376,34 +1368,26 @@ function initSearch(rawSearchIndex) {
1376
1368
continue ;
1377
1369
}
1378
1370
if ( fnType . id < 0 ) {
1379
- if ( mgens === null ) {
1380
- mgens = new Map ( ) ;
1381
- }
1382
- const alreadyAssigned = mgens . has ( fnType . id ) ;
1383
- if ( alreadyAssigned ) {
1384
- if ( mgens . get ( fnType . id ) !== 0 ) {
1385
- continue ;
1386
- }
1387
- } else {
1388
- mgens . set ( fnType . id , 0 ) ;
1371
+ if ( mgens && mgens . has ( fnType . id ) &&
1372
+ mgens . get ( fnType . id ) !== 0 ) {
1373
+ continue ;
1389
1374
}
1375
+ const mgensScratch = new Map ( mgens ) ;
1376
+ mgensScratch . set ( fnType . id , 0 ) ;
1390
1377
if ( unifyFunctionTypes (
1391
1378
whereClause [ ( - fnType . id ) - 1 ] ,
1392
1379
queryElems ,
1393
1380
whereClause ,
1394
- mgens ,
1381
+ mgensScratch ,
1395
1382
solutionCb
1396
1383
) ) {
1397
1384
return true ;
1398
1385
}
1399
- if ( ! alreadyAssigned ) {
1400
- mgens . delete ( fnType . id ) ;
1401
- }
1402
1386
} else if ( unifyFunctionTypes (
1403
1387
fnType . generics ,
1404
1388
queryElems ,
1405
1389
whereClause ,
1406
- mgens ,
1390
+ mgens ? new Map ( mgens ) : null ,
1407
1391
solutionCb
1408
1392
) ) {
1409
1393
return true ;
0 commit comments