@@ -1412,17 +1412,16 @@ class DocSearch {
1412
1412
* query fingerprint. If any bits are set in the query but not in the function, it can't
1413
1413
* match.
1414
1414
*
1415
- * - The fourth section has the number of distinct items in the set.
1415
+ * - The fourth section has the number of items in the set.
1416
1416
* This is the distance function, used for filtering and for sorting.
1417
1417
*
1418
1418
* [^1]: Distance is the relatively naive metric of counting the number of distinct items in
1419
1419
* the function that are not present in the query.
1420
1420
*
1421
1421
* @param {FunctionType|QueryElement } type - a single type
1422
1422
* @param {Uint32Array } output - write the fingerprint to this data structure: uses 128 bits
1423
- * @param {Set<number> } fps - Set of distinct items
1424
1423
*/
1425
- buildFunctionTypeFingerprint ( type , output , fps ) {
1424
+ buildFunctionTypeFingerprint ( type , output ) {
1426
1425
let input = type . id ;
1427
1426
// All forms of `[]`/`()`/`->` get collapsed down to one thing in the bloom filter.
1428
1427
// Differentiating between arrays and slices, if the user asks for it, is
@@ -1468,10 +1467,11 @@ class DocSearch {
1468
1467
output [ 0 ] |= ( 1 << ( h0a % 32 ) ) | ( 1 << ( h1b % 32 ) ) ;
1469
1468
output [ 1 ] |= ( 1 << ( h1a % 32 ) ) | ( 1 << ( h2b % 32 ) ) ;
1470
1469
output [ 2 ] |= ( 1 << ( h2a % 32 ) ) | ( 1 << ( h0b % 32 ) ) ;
1471
- fps . add ( input ) ;
1470
+ // output[3] is the total number of items in the type signature
1471
+ output [ 3 ] += 1 ;
1472
1472
}
1473
1473
for ( const g of type . generics ) {
1474
- this . buildFunctionTypeFingerprint ( g , output , fps ) ;
1474
+ this . buildFunctionTypeFingerprint ( g , output ) ;
1475
1475
}
1476
1476
const fb = {
1477
1477
id : null ,
@@ -1482,9 +1482,8 @@ class DocSearch {
1482
1482
for ( const [ k , v ] of type . bindings . entries ( ) ) {
1483
1483
fb . id = k ;
1484
1484
fb . generics = v ;
1485
- this . buildFunctionTypeFingerprint ( fb , output , fps ) ;
1485
+ this . buildFunctionTypeFingerprint ( fb , output ) ;
1486
1486
}
1487
- output [ 3 ] = fps . size ;
1488
1487
}
1489
1488
1490
1489
/**
@@ -1734,16 +1733,15 @@ class DocSearch {
1734
1733
if ( type !== null ) {
1735
1734
if ( type ) {
1736
1735
const fp = this . functionTypeFingerprint . subarray ( id * 4 , ( id + 1 ) * 4 ) ;
1737
- const fps = new Set ( ) ;
1738
1736
for ( const t of type . inputs ) {
1739
- this . buildFunctionTypeFingerprint ( t , fp , fps ) ;
1737
+ this . buildFunctionTypeFingerprint ( t , fp ) ;
1740
1738
}
1741
1739
for ( const t of type . output ) {
1742
- this . buildFunctionTypeFingerprint ( t , fp , fps ) ;
1740
+ this . buildFunctionTypeFingerprint ( t , fp ) ;
1743
1741
}
1744
1742
for ( const w of type . where_clause ) {
1745
1743
for ( const t of w ) {
1746
- this . buildFunctionTypeFingerprint ( t , fp , fps ) ;
1744
+ this . buildFunctionTypeFingerprint ( t , fp ) ;
1747
1745
}
1748
1746
}
1749
1747
}
@@ -3885,14 +3883,13 @@ class DocSearch {
3885
3883
) ;
3886
3884
} ;
3887
3885
3888
- const fps = new Set ( ) ;
3889
3886
for ( const elem of parsedQuery . elems ) {
3890
3887
convertNameToId ( elem ) ;
3891
- this . buildFunctionTypeFingerprint ( elem , parsedQuery . typeFingerprint , fps ) ;
3888
+ this . buildFunctionTypeFingerprint ( elem , parsedQuery . typeFingerprint ) ;
3892
3889
}
3893
3890
for ( const elem of parsedQuery . returned ) {
3894
3891
convertNameToId ( elem ) ;
3895
- this . buildFunctionTypeFingerprint ( elem , parsedQuery . typeFingerprint , fps ) ;
3892
+ this . buildFunctionTypeFingerprint ( elem , parsedQuery . typeFingerprint ) ;
3896
3893
}
3897
3894
3898
3895
if ( parsedQuery . foundElems === 1 && ! parsedQuery . hasReturnArrow ) {
0 commit comments