@@ -1825,6 +1825,24 @@ function initSearch(rawSearchIndex) {
18251825 filterCrates ) ;
18261826 }
18271827
1828+ /**
1829+ * Convert a list of RawFunctionType / ID to object-based FunctionType.
1830+ *
1831+ * Crates often have lots of functions in them, and it's common to have a large number of
1832+ * functions that operate on a small set of data types, so the search index compresses them
1833+ * by encoding function parameter and return types as indexes into an array of names.
1834+ *
1835+ * Even when a general-purpose compression algorithm is used, this is still a win. I checked.
1836+ * https://github.com/rust-lang/rust/pull/98475#issue-1284395985
1837+ *
1838+ * The format for individual function types is encoded in
1839+ * librustdoc/html/render/mod.rs: impl Serialize for RenderType
1840+ *
1841+ * @param {null|Array<RawFunctionType> } types
1842+ * @param {Array<{name: string, ty: number}> } lowercasePaths
1843+ *
1844+ * @return {Array<FunctionSearchType> }
1845+ */
18281846 function buildItemSearchTypeAll ( types , lowercasePaths ) {
18291847 const PATH_INDEX_DATA = 0 ;
18301848 const GENERICS_DATA = 1 ;
@@ -1848,6 +1866,21 @@ function initSearch(rawSearchIndex) {
18481866 } ) ;
18491867 }
18501868
1869+ /**
1870+ * Convert from RawFunctionSearchType to FunctionSearchType.
1871+ *
1872+ * Crates often have lots of functions in them, and function signatures are sometimes complex,
1873+ * so rustdoc uses a pretty tight encoding for them. This function converts it to a simpler,
1874+ * object-based encoding so that the actual search code is more readable and easier to debug.
1875+ *
1876+ * The raw function search type format is generated using serde in
1877+ * librustdoc/html/render/mod.rs: impl Serialize for IndexItemFunctionType
1878+ *
1879+ * @param {RawFunctionSearchType } functionSearchType
1880+ * @param {Array<{name: string, ty: number}> } lowercasePaths
1881+ *
1882+ * @return {null|FunctionSearchType }
1883+ */
18511884 function buildFunctionSearchType ( functionSearchType , lowercasePaths ) {
18521885 const INPUTS_DATA = 0 ;
18531886 const OUTPUT_DATA = 1 ;
@@ -1935,7 +1968,7 @@ function initSearch(rawSearchIndex) {
19351968 * d: Array<string>,
19361969 * q: Array<string>,
19371970 * i: Array<Number>,
1938- * f: Array<0 | Object >,
1971+ * f: Array<RawFunctionSearchType >,
19391972 * p: Array<Object>,
19401973 * }}
19411974 */
0 commit comments