@@ -2283,7 +2283,7 @@ function initSearch(rawSearchIndex) {
2283
2283
parsedQuery . elems . sort ( sortQ ) ;
2284
2284
parsedQuery . returned . sort ( sortQ ) ;
2285
2285
for ( i = 0 , nSearchWords = searchWords . length ; i < nSearchWords ; ++ i ) {
2286
- handleArgs ( searchIndex [ i ] , i , results_others ) ;
2286
+ handleArgs ( searchIndex [ i ] , searchIndex [ i ] . id , results_others ) ;
2287
2287
}
2288
2288
}
2289
2289
}
@@ -2847,23 +2847,42 @@ ${item.displayPath}<span class="${type}">${name}</span>\
2847
2847
* @param {Set<number> } fps - Set of distinct items
2848
2848
*/
2849
2849
function buildFunctionTypeFingerprint ( type , output , fps ) {
2850
-
2851
2850
let input = type . id ;
2852
2851
// All forms of `[]` get collapsed down to one thing in the bloom filter.
2853
2852
// Differentiating between arrays and slices, if the user asks for it, is
2854
2853
// still done in the matching algorithm.
2855
2854
if ( input === typeNameIdOfArray || input === typeNameIdOfSlice ) {
2856
2855
input = typeNameIdOfArrayOrSlice ;
2857
2856
}
2857
+ // http://burtleburtle.net/bob/hash/integer.html
2858
+ // ~~ is toInt32. It's used before adding, so
2859
+ // the number stays in safe integer range.
2860
+ const hashint1 = k => {
2861
+ k = ( ~ ~ k + 0x7ed55d16 ) + ( k << 12 ) ;
2862
+ k = ( k ^ 0xc761c23c ) ^ ( k >>> 19 ) ;
2863
+ k = ( ~ ~ k + 0x165667b1 ) + ( k << 5 ) ;
2864
+ k = ( ~ ~ k + 0xd3a2646c ) ^ ( k << 9 ) ;
2865
+ k = ( ~ ~ k + 0xfd7046c5 ) + ( k << 3 ) ;
2866
+ return ( k ^ 0xb55a4f09 ) ^ ( k >>> 16 ) ;
2867
+ } ;
2868
+ const hashint2 = k => {
2869
+ k = ~ k + ( k << 15 ) ;
2870
+ k ^= k >>> 12 ;
2871
+ k += k << 2 ;
2872
+ k ^= k >>> 4 ;
2873
+ k = Math . imul ( k , 2057 ) ;
2874
+ return k ^ ( k >> 16 ) ;
2875
+ } ;
2858
2876
if ( input !== null ) {
2859
- // https://docs.rs/rustc-hash/1.1.0/src/rustc_hash/lib.rs.html#60
2860
- // Rotate is skipped because we're only doing one cycle anyway.
2861
- const h0 = Math . imul ( input , 0x9e3779b9 ) ;
2862
- const h1 = Math . imul ( 479001599 ^ input , 0x9e3779b9 ) ;
2863
- const h2 = Math . imul ( 433494437 ^ input , 0x9e3779b9 ) ;
2864
- output [ 0 ] |= 1 << ( h0 % 32 ) ;
2865
- output [ 1 ] |= 1 << ( h1 % 32 ) ;
2866
- output [ 2 ] |= 1 << ( h2 % 32 ) ;
2877
+ const h0a = hashint1 ( input ) ;
2878
+ const h0b = hashint2 ( input ) ;
2879
+ const h1a = hashint1 ( 479001599 ^ input ) ;
2880
+ const h1b = hashint2 ( 479001599 ^ input ) ;
2881
+ const h2a = hashint1 ( 433494437 ^ input ) ;
2882
+ const h2b = hashint2 ( 433494437 ^ input ) ;
2883
+ output [ 0 ] |= ( 1 << ( h0a % 32 ) ) | ( 1 << ( h0b % 32 ) ) ;
2884
+ output [ 1 ] |= ( 1 << ( h1a % 32 ) ) | ( 1 << ( h1b % 32 ) ) ;
2885
+ output [ 2 ] |= ( 1 << ( h2a % 32 ) ) | ( 1 << ( h2b % 32 ) ) ;
2867
2886
fps . add ( input ) ;
2868
2887
}
2869
2888
for ( const g of type . generics ) {
@@ -2892,7 +2911,6 @@ ${item.displayPath}<span class="${type}">${name}</span>\
2892
2911
* This function might return 0!
2893
2912
*/
2894
2913
function compareTypeFingerprints ( fullId , queryFingerprint ) {
2895
-
2896
2914
const fh0 = functionTypeFingerprint [ fullId * 4 ] ;
2897
2915
const fh1 = functionTypeFingerprint [ ( fullId * 4 ) + 1 ] ;
2898
2916
const fh2 = functionTypeFingerprint [ ( fullId * 4 ) + 2 ] ;
0 commit comments