rustdoc-search: null
, not -1
, for missing id
This allows us to use negative numbers for others purposes.
This commit is contained in:
parent
2a1af898b2
commit
217fe24e52
2 changed files with 14 additions and 14 deletions
|
@ -9,7 +9,7 @@ function initSearch(searchIndex){}
|
||||||
/**
|
/**
|
||||||
* @typedef {{
|
* @typedef {{
|
||||||
* name: string,
|
* name: string,
|
||||||
* id: integer,
|
* id: integer|null,
|
||||||
* fullPath: Array<string>,
|
* fullPath: Array<string>,
|
||||||
* pathWithoutLast: Array<string>,
|
* pathWithoutLast: Array<string>,
|
||||||
* pathLast: string,
|
* pathLast: string,
|
||||||
|
|
|
@ -252,7 +252,7 @@ function initSearch(rawSearchIndex) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add an item to the type Name->ID map, or, if one already exists, use it.
|
* Add an item to the type Name->ID map, or, if one already exists, use it.
|
||||||
* Returns the number. If name is "" or null, return -1 (pure generic).
|
* Returns the number. If name is "" or null, return null (pure generic).
|
||||||
*
|
*
|
||||||
* This is effectively string interning, so that function matching can be
|
* This is effectively string interning, so that function matching can be
|
||||||
* done more quickly. Two types with the same name but different item kinds
|
* done more quickly. Two types with the same name but different item kinds
|
||||||
|
@ -264,7 +264,7 @@ function initSearch(rawSearchIndex) {
|
||||||
*/
|
*/
|
||||||
function buildTypeMapIndex(name) {
|
function buildTypeMapIndex(name) {
|
||||||
if (name === "" || name === null) {
|
if (name === "" || name === null) {
|
||||||
return -1;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeNameIdMap.has(name)) {
|
if (typeNameIdMap.has(name)) {
|
||||||
|
@ -489,7 +489,7 @@ function initSearch(rawSearchIndex) {
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
name: "never",
|
name: "never",
|
||||||
id: -1,
|
id: null,
|
||||||
fullPath: ["never"],
|
fullPath: ["never"],
|
||||||
pathWithoutLast: [],
|
pathWithoutLast: [],
|
||||||
pathLast: "never",
|
pathLast: "never",
|
||||||
|
@ -531,7 +531,7 @@ function initSearch(rawSearchIndex) {
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
name: name.trim(),
|
name: name.trim(),
|
||||||
id: -1,
|
id: null,
|
||||||
fullPath: pathSegments,
|
fullPath: pathSegments,
|
||||||
pathWithoutLast: pathSegments.slice(0, pathSegments.length - 1),
|
pathWithoutLast: pathSegments.slice(0, pathSegments.length - 1),
|
||||||
pathLast: pathSegments[pathSegments.length - 1],
|
pathLast: pathSegments[pathSegments.length - 1],
|
||||||
|
@ -660,7 +660,7 @@ function initSearch(rawSearchIndex) {
|
||||||
}
|
}
|
||||||
elems.push({
|
elems.push({
|
||||||
name: "[]",
|
name: "[]",
|
||||||
id: -1,
|
id: null,
|
||||||
fullPath: ["[]"],
|
fullPath: ["[]"],
|
||||||
pathWithoutLast: [],
|
pathWithoutLast: [],
|
||||||
pathLast: "[]",
|
pathLast: "[]",
|
||||||
|
@ -1172,7 +1172,7 @@ function initSearch(rawSearchIndex) {
|
||||||
const out = [];
|
const out = [];
|
||||||
|
|
||||||
for (const result of results) {
|
for (const result of results) {
|
||||||
if (result.id > -1) {
|
if (result.id !== -1) {
|
||||||
const obj = searchIndex[result.id];
|
const obj = searchIndex[result.id];
|
||||||
obj.dist = result.dist;
|
obj.dist = result.dist;
|
||||||
const res = buildHrefAndPath(obj);
|
const res = buildHrefAndPath(obj);
|
||||||
|
@ -1403,7 +1403,7 @@ function initSearch(rawSearchIndex) {
|
||||||
// [unboxing]:
|
// [unboxing]:
|
||||||
// http://ndmitchell.com/downloads/slides-hoogle_fast_type_searching-09_aug_2008.pdf
|
// http://ndmitchell.com/downloads/slides-hoogle_fast_type_searching-09_aug_2008.pdf
|
||||||
const queryContainsArrayOrSliceElem = queryElemSet.has(typeNameIdOfArrayOrSlice);
|
const queryContainsArrayOrSliceElem = queryElemSet.has(typeNameIdOfArrayOrSlice);
|
||||||
if (fnType.id === -1 || !(
|
if (fnType.id === null || !(
|
||||||
queryElemSet.has(fnType.id) ||
|
queryElemSet.has(fnType.id) ||
|
||||||
(fnType.id === typeNameIdOfSlice && queryContainsArrayOrSliceElem) ||
|
(fnType.id === typeNameIdOfSlice && queryContainsArrayOrSliceElem) ||
|
||||||
(fnType.id === typeNameIdOfArray && queryContainsArrayOrSliceElem)
|
(fnType.id === typeNameIdOfArray && queryContainsArrayOrSliceElem)
|
||||||
|
@ -1564,7 +1564,7 @@ function initSearch(rawSearchIndex) {
|
||||||
* @return {boolean} - Returns true if the type matches, false otherwise.
|
* @return {boolean} - Returns true if the type matches, false otherwise.
|
||||||
*/
|
*/
|
||||||
function checkType(row, elem) {
|
function checkType(row, elem) {
|
||||||
if (row.id === -1) {
|
if (row.id === null) {
|
||||||
// This is a pure "generic" search, no need to run other checks.
|
// This is a pure "generic" search, no need to run other checks.
|
||||||
return row.generics.length > 0 ? checkIfInList(row.generics, elem) : false;
|
return row.generics.length > 0 ? checkIfInList(row.generics, elem) : false;
|
||||||
}
|
}
|
||||||
|
@ -1891,7 +1891,7 @@ function initSearch(rawSearchIndex) {
|
||||||
if (typeNameIdMap.has(elem.pathLast)) {
|
if (typeNameIdMap.has(elem.pathLast)) {
|
||||||
elem.id = typeNameIdMap.get(elem.pathLast);
|
elem.id = typeNameIdMap.get(elem.pathLast);
|
||||||
} else if (!parsedQuery.literalSearch) {
|
} else if (!parsedQuery.literalSearch) {
|
||||||
let match = -1;
|
let match = null;
|
||||||
let matchDist = maxEditDistance + 1;
|
let matchDist = maxEditDistance + 1;
|
||||||
let matchName = "";
|
let matchName = "";
|
||||||
for (const [name, id] of typeNameIdMap) {
|
for (const [name, id] of typeNameIdMap) {
|
||||||
|
@ -1905,7 +1905,7 @@ function initSearch(rawSearchIndex) {
|
||||||
matchName = name;
|
matchName = name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (match !== -1) {
|
if (match !== null) {
|
||||||
parsedQuery.correction = matchName;
|
parsedQuery.correction = matchName;
|
||||||
}
|
}
|
||||||
elem.id = match;
|
elem.id = match;
|
||||||
|
@ -2413,7 +2413,7 @@ ${item.displayPath}<span class="${type}">${name}</span>\
|
||||||
// `0` is used as a sentinel because it's fewer bytes than `null`
|
// `0` is used as a sentinel because it's fewer bytes than `null`
|
||||||
if (pathIndex === 0) {
|
if (pathIndex === 0) {
|
||||||
return {
|
return {
|
||||||
id: -1,
|
id: null,
|
||||||
ty: null,
|
ty: null,
|
||||||
path: null,
|
path: null,
|
||||||
generics: generics,
|
generics: generics,
|
||||||
|
@ -2457,7 +2457,7 @@ ${item.displayPath}<span class="${type}">${name}</span>\
|
||||||
const pathIndex = functionSearchType[INPUTS_DATA];
|
const pathIndex = functionSearchType[INPUTS_DATA];
|
||||||
if (pathIndex === 0) {
|
if (pathIndex === 0) {
|
||||||
inputs = [{
|
inputs = [{
|
||||||
id: -1,
|
id: null,
|
||||||
ty: null,
|
ty: null,
|
||||||
path: null,
|
path: null,
|
||||||
generics: [],
|
generics: [],
|
||||||
|
@ -2482,7 +2482,7 @@ ${item.displayPath}<span class="${type}">${name}</span>\
|
||||||
const pathIndex = functionSearchType[OUTPUT_DATA];
|
const pathIndex = functionSearchType[OUTPUT_DATA];
|
||||||
if (pathIndex === 0) {
|
if (pathIndex === 0) {
|
||||||
output = [{
|
output = [{
|
||||||
id: -1,
|
id: null,
|
||||||
ty: null,
|
ty: null,
|
||||||
path: null,
|
path: null,
|
||||||
generics: [],
|
generics: [],
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue