@@ -1308,36 +1308,6 @@ function initSearch(rawSearchIndex) {
1308
1308
return transformResults ( result_list ) ;
1309
1309
}
1310
1310
1311
- /**
1312
- * This function checks generics in search query `queryElem` can all be found in the
1313
- * search index (`fnType`),
1314
- *
1315
- * This function returns `true` if it matches, and also writes the results to mgensInout.
1316
- * It returns `false` if no match is found, and leaves mgensInout untouched.
1317
- *
1318
- * @param {FunctionType } fnType - The object to check.
1319
- * @param {QueryElement } queryElem - The element from the parsed query.
1320
- * @param {[FunctionType] } whereClause - Trait bounds for generic items.
1321
- * @param {Map<number,number>|null } mgensInout - Map functions generics to query generics.
1322
- *
1323
- * @return {boolean } - Returns true if a match, false otherwise.
1324
- */
1325
- function checkGenerics ( fnType , queryElem , whereClause , mgensInout ) {
1326
- return unifyFunctionTypes (
1327
- fnType . generics ,
1328
- queryElem . generics ,
1329
- whereClause ,
1330
- mgensInout ,
1331
- mgens => {
1332
- if ( mgensInout ) {
1333
- for ( const [ fid , qid ] of mgens . entries ( ) ) {
1334
- mgensInout . set ( fid , qid ) ;
1335
- }
1336
- }
1337
- return true ;
1338
- }
1339
- ) ;
1340
- }
1341
1311
/**
1342
1312
* This function checks if a list of search query `queryElems` can all be found in the
1343
1313
* search index (`fnTypes`).
@@ -1561,7 +1531,7 @@ function initSearch(rawSearchIndex) {
1561
1531
) {
1562
1532
// [] matches primitive:array or primitive:slice
1563
1533
// if it matches, then we're fine, and this is an appropriate match candidate
1564
- } else if ( fnType . id !== queryElem . id ) {
1534
+ } else if ( fnType . id !== queryElem . id || queryElem . id === null ) {
1565
1535
return false ;
1566
1536
}
1567
1537
// If the query elem has generics, and the function doesn't,
@@ -1649,38 +1619,17 @@ function initSearch(rawSearchIndex) {
1649
1619
* @return {boolean } - Returns true if the type matches, false otherwise.
1650
1620
*/
1651
1621
function checkType ( row , elem , whereClause ) {
1652
- if ( row . id === null ) {
1653
- // This is a pure "generic" search, no need to run other checks.
1654
- return row . generics . length > 0
1655
- ? checkIfInList ( row . generics , elem , whereClause )
1656
- : false ;
1657
- }
1658
-
1659
- if ( row . id < 0 && elem . id >= 0 ) {
1660
- const gid = ( - row . id ) - 1 ;
1661
- return checkIfInList ( whereClause [ gid ] , elem , whereClause ) ;
1662
- }
1663
-
1664
- if ( row . id < 0 && elem . id < 0 ) {
1665
- return true ;
1622
+ if ( elem . id < 0 ) {
1623
+ return row . id < 0 || checkIfInList ( row . generics , elem , whereClause ) ;
1666
1624
}
1667
-
1668
- const matchesExact = row . id === elem . id ;
1669
- const matchesArrayOrSlice = elem . id === typeNameIdOfArrayOrSlice &&
1670
- ( row . id === typeNameIdOfSlice || row . id === typeNameIdOfArray ) ;
1671
-
1672
- if ( ( matchesExact || matchesArrayOrSlice ) &&
1673
- typePassesFilter ( elem . typeFilter , row . ty ) ) {
1674
- if ( elem . generics . length > 0 ) {
1675
- return checkGenerics ( row , elem , whereClause , new Map ( ) ) ;
1676
- }
1677
- return true ;
1625
+ if ( row . id > 0 && elem . id > 0 && elem . pathWithoutLast . length === 0 &&
1626
+ typePassesFilter ( elem . typeFilter , row . ty ) && elem . generics . length === 0 &&
1627
+ // special case
1628
+ elem . id !== typeNameIdOfArrayOrSlice
1629
+ ) {
1630
+ return row . id === elem . id || checkIfInList ( row . generics , elem , whereClause ) ;
1678
1631
}
1679
-
1680
- // If the current item does not match, try [unboxing] the generic.
1681
- // [unboxing]:
1682
- // https://ndmitchell.com/downloads/slides-hoogle_fast_type_searching-09_aug_2008.pdf
1683
- return checkIfInList ( row . generics , elem , whereClause ) ;
1632
+ return unifyFunctionTypes ( [ row ] , [ elem ] , whereClause ) ;
1684
1633
}
1685
1634
1686
1635
function checkPath ( contains , ty , maxEditDistance ) {
0 commit comments