diff --git a/src/librustdoc/html/static/js/search.js b/src/librustdoc/html/static/js/search.js
index 843258e6a815..0dacd4f0918b 100644
--- a/src/librustdoc/html/static/js/search.js
+++ b/src/librustdoc/html/static/js/search.js
@@ -2283,7 +2283,7 @@ function initSearch(rawSearchIndex) {
parsedQuery.elems.sort(sortQ);
parsedQuery.returned.sort(sortQ);
for (i = 0, nSearchWords = searchWords.length; i < nSearchWords; ++i) {
- handleArgs(searchIndex[i], i, results_others);
+ handleArgs(searchIndex[i], searchIndex[i].id, results_others);
}
}
}
@@ -2847,7 +2847,6 @@ ${item.displayPath}${name}\
* @param {Set} fps - Set of distinct items
*/
function buildFunctionTypeFingerprint(type, output, fps) {
-
let input = type.id;
// All forms of `[]` get collapsed down to one thing in the bloom filter.
// Differentiating between arrays and slices, if the user asks for it, is
@@ -2855,15 +2854,35 @@ ${item.displayPath}${name}\
if (input === typeNameIdOfArray || input === typeNameIdOfSlice) {
input = typeNameIdOfArrayOrSlice;
}
+ // http://burtleburtle.net/bob/hash/integer.html
+ // ~~ is toInt32. It's used before adding, so
+ // the number stays in safe integer range.
+ const hashint1 = k => {
+ k = (~~k + 0x7ed55d16) + (k << 12);
+ k = (k ^ 0xc761c23c) ^ (k >>> 19);
+ k = (~~k + 0x165667b1) + (k << 5);
+ k = (~~k + 0xd3a2646c) ^ (k << 9);
+ k = (~~k + 0xfd7046c5) + (k << 3);
+ return (k ^ 0xb55a4f09) ^ (k >>> 16);
+ };
+ const hashint2 = k => {
+ k = ~k + (k << 15);
+ k ^= k >>> 12;
+ k += k << 2;
+ k ^= k >>> 4;
+ k = Math.imul(k, 2057);
+ return k ^ (k >> 16);
+ };
if (input !== null) {
- // https://docs.rs/rustc-hash/1.1.0/src/rustc_hash/lib.rs.html#60
- // Rotate is skipped because we're only doing one cycle anyway.
- const h0 = Math.imul(input, 0x9e3779b9);
- const h1 = Math.imul(479001599 ^ input, 0x9e3779b9);
- const h2 = Math.imul(433494437 ^ input, 0x9e3779b9);
- output[0] |= 1 << (h0 % 32);
- output[1] |= 1 << (h1 % 32);
- output[2] |= 1 << (h2 % 32);
+ const h0a = hashint1(input);
+ const h0b = hashint2(input);
+ const h1a = hashint1(479001599 ^ input);
+ const h1b = hashint2(479001599 ^ input);
+ const h2a = hashint1(433494437 ^ input);
+ const h2b = hashint2(433494437 ^ input);
+ output[0] |= (1 << (h0a % 32)) | (1 << (h0b % 32));
+ output[1] |= (1 << (h1a % 32)) | (1 << (h1b % 32));
+ output[2] |= (1 << (h2a % 32)) | (1 << (h2b % 32));
fps.add(input);
}
for (const g of type.generics) {
@@ -2892,7 +2911,6 @@ ${item.displayPath}${name}\
* This function might return 0!
*/
function compareTypeFingerprints(fullId, queryFingerprint) {
-
const fh0 = functionTypeFingerprint[fullId * 4];
const fh1 = functionTypeFingerprint[(fullId * 4) + 1];
const fh2 = functionTypeFingerprint[(fullId * 4) + 2];