@@ -1412,17 +1412,16 @@ class DocSearch {
14121412 * query fingerprint. If any bits are set in the query but not in the function, it can't
14131413 * match.
14141414 *
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.
14161416 * This is the distance function, used for filtering and for sorting.
14171417 *
14181418 * [^1]: Distance is the relatively naive metric of counting the number of distinct items in
14191419 * the function that are not present in the query.
14201420 *
14211421 * @param {FunctionType|QueryElement } type - a single type
14221422 * @param {Uint32Array } output - write the fingerprint to this data structure: uses 128 bits
1423- * @param {Set<number> } fps - Set of distinct items
14241423 */
1425- buildFunctionTypeFingerprint ( type , output , fps ) {
1424+ buildFunctionTypeFingerprint ( type , output ) {
14261425 let input = type . id ;
14271426 // All forms of `[]`/`()`/`->` get collapsed down to one thing in the bloom filter.
14281427 // Differentiating between arrays and slices, if the user asks for it, is
@@ -1468,10 +1467,11 @@ class DocSearch {
14681467 output [ 0 ] |= ( 1 << ( h0a % 32 ) ) | ( 1 << ( h1b % 32 ) ) ;
14691468 output [ 1 ] |= ( 1 << ( h1a % 32 ) ) | ( 1 << ( h2b % 32 ) ) ;
14701469 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 ;
14721472 }
14731473 for ( const g of type . generics ) {
1474- this . buildFunctionTypeFingerprint ( g , output , fps ) ;
1474+ this . buildFunctionTypeFingerprint ( g , output ) ;
14751475 }
14761476 const fb = {
14771477 id : null ,
@@ -1482,9 +1482,8 @@ class DocSearch {
14821482 for ( const [ k , v ] of type . bindings . entries ( ) ) {
14831483 fb . id = k ;
14841484 fb . generics = v ;
1485- this . buildFunctionTypeFingerprint ( fb , output , fps ) ;
1485+ this . buildFunctionTypeFingerprint ( fb , output ) ;
14861486 }
1487- output [ 3 ] = fps . size ;
14881487 }
14891488
14901489 /**
@@ -1734,16 +1733,15 @@ class DocSearch {
17341733 if ( type !== null ) {
17351734 if ( type ) {
17361735 const fp = this . functionTypeFingerprint . subarray ( id * 4 , ( id + 1 ) * 4 ) ;
1737- const fps = new Set ( ) ;
17381736 for ( const t of type . inputs ) {
1739- this . buildFunctionTypeFingerprint ( t , fp , fps ) ;
1737+ this . buildFunctionTypeFingerprint ( t , fp ) ;
17401738 }
17411739 for ( const t of type . output ) {
1742- this . buildFunctionTypeFingerprint ( t , fp , fps ) ;
1740+ this . buildFunctionTypeFingerprint ( t , fp ) ;
17431741 }
17441742 for ( const w of type . where_clause ) {
17451743 for ( const t of w ) {
1746- this . buildFunctionTypeFingerprint ( t , fp , fps ) ;
1744+ this . buildFunctionTypeFingerprint ( t , fp ) ;
17471745 }
17481746 }
17491747 }
@@ -3885,14 +3883,13 @@ class DocSearch {
38853883 ) ;
38863884 } ;
38873885
3888- const fps = new Set ( ) ;
38893886 for ( const elem of parsedQuery . elems ) {
38903887 convertNameToId ( elem ) ;
3891- this . buildFunctionTypeFingerprint ( elem , parsedQuery . typeFingerprint , fps ) ;
3888+ this . buildFunctionTypeFingerprint ( elem , parsedQuery . typeFingerprint ) ;
38923889 }
38933890 for ( const elem of parsedQuery . returned ) {
38943891 convertNameToId ( elem ) ;
3895- this . buildFunctionTypeFingerprint ( elem , parsedQuery . typeFingerprint , fps ) ;
3892+ this . buildFunctionTypeFingerprint ( elem , parsedQuery . typeFingerprint ) ;
38963893 }
38973894
38983895 if ( parsedQuery . foundElems === 1 && ! parsedQuery . hasReturnArrow ) {
0 commit comments